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
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.