Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

print all numbers from 1 to n java

// Java Program to Print Natural Numbers from 1 to N 
import java.util.Scanner;

public class NaturalNumbers1 {
	private static Scanner sc;
	public static void main(String[] args) 
	{
		int number, i;
		sc = new Scanner(System.in);
		
		System.out.print(" Please Enter any Number : ");
		number = sc.nextInt();	
		
		for(i = 1; i <= number; i++)
		{
			System.out.print(i +"	"); 
		}	
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: java string join 
Java :: Hash map, Hash set and Hash Table difference 
Java :: Spigot coding how to send a message to player after commadn 
Java :: dockerfile for spring boot app 
Java :: char array to string in java 
Java :: what is static setter and getter examples in java 
Java :: set text in edittext android 
Java :: java string vers int 
Java :: how to get cpu model number in android programmatically 
Java :: java run jar with args 
Java :: pass a function as parameter 
Java :: java for item in array 
Java :: declare function in java 
Java :: java static variable 
Java :: array of arrays java 
Java :: crit chance in java 
Java :: java add a list to a list 
Java :: ClassNotFoundException: org.springframework.ui.freemarker.FreeMarkerConfigurationFactory 
Java :: org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:876) 
Java :: Java display form 
Java :: stack initialization for string java 
Java :: algorithm to know if a number is an integer 
Java :: Data provider using junit 
Java :: export java path in ubuntu 
Java :: java array object 
Java :: spring cli version 
Java :: jhow to check if a string is a punctuation java 
Java :: close GUI in jvava 
Java :: java linkedlist poll 
Java :: bool in java 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =