Write a program to print each number from 1 to n on a new line.
>Input Format
For each test case, you will get n as an integer input.
Constraints
1<=n<=1000
Output Format
Print each number on a new line.
Sample Input 0
5
Sample Output 0
1
2
3
4
5
Explanation 0
print numbers from 1 to 5.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int i=1;
while(i<=n){
System.out.println(i);
i++;
}
}
}
Watch more