import java.io.*; import java.lang.*; class Num { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the number:"); int n=Integer.parseInt(br.readLine()); System.out.println("Numbers are"); for(int i=1; i<=n; i++) System.out.println(i); } }
OUTPUT:
Compile :javac Num.java Run :java Num Enter the number: 8 Numbers are 1 2 3 4 5 6 7 8