Question
Zero Destination
You are given an integer N.
Your task is to print all numbers starting from N and moving step-by-step towards 0.
- If N is positive, print numbers from N down to 0.
- If N is negative, print numbers from N up to 0.
- 0 should always be included in the output.
Each number must be printed on a new line.
Input
A single integer
N.Output
Print all numbers from
N to 0, each on a new line, moving in steps of 1.
Example
Example 1
Input:
5
Output:
5
4
3
2
1
0
Explanation:
The given number is 5
We print all numbers from N down to 0, one per line.
So the printed sequence is:
5
4
3
2
1
0
Example 2
Input:
-4
Output:
-4
-3
-2
-1
0
Explanation:
The given number is -4
Since we must print numbers until we reach 0, we move upward, one step at a time, printing each value on a new line
So the printed sequence is:
-4
-3
-2
-1
0
Input:
5
Output:
5
4
3
2
1
0
Explanation:
The given number is 5
We print all numbers from N down to 0, one per line.
So the printed sequence is:
5
4
3
2
1
0
Example 2
Input:
-4
Output:
-4
-3
-2
-1
0
Explanation:
The given number is -4
Since we must print numbers until we reach 0, we move upward, one step at a time, printing each value on a new line
So the printed sequence is:
-4
-3
-2
-1
0