203. Countdown
Foundation1000 ms256 MBSolved by 0%
Print the numbers from n down to 1, one per line.
Do it recursively: print n, then handle n - 1.
Then change the order of those two statements and watch what happens. Printing before the call counts down; printing after it counts up. Nothing else changes. That is worth doing once, because it is the clearest demonstration of what the call stack is actually holding.
Constraints - `1 ≤ n ≤ 10000`
Input
A single line containing one integer n.
Output
Print n lines: the numbers from n down to 1, one per line.
Input5
Output5
4
3
2
1
Noteis the ordinary case
Input1
Output1
Noteis the base case, printing one line and stopping
Hint 1Approach
Hint 2Approach
Hint 3Pseudocode
Hint 4Full solution