Count to N

Lab Java Beginner 10 points

Read n and print 1 to n on one line separated by spaces.

Input

One integer ≥ 1.

Output

One line.

Example

Input

5

Output

1 2 3 4 5
Sample input available Sample output available
Editor
Java

Hints

for (int i = 1; i <= n; i++) counts from 1 to n.

Solution explanation

The three parts of a for header are: start, condition, update.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            System.out.print(i + (i < n ? " " : "\n"));
        }
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD