240. Print the Digits Forwards
Print the digits of n in order, one per line, most significant first.
The only easy way to take digits off a number is from the RIGHT, using % 10
and / 10. So the digits come out backwards, and you are asked for them
forwards.
Recursion solves this without reversing anything. Recurse FIRST, then print. The deepest call holds the leftmost digit and finishes first, so the printing happens on the way back up.
This is the clearest demonstration of what the call stack is actually holding, and it is worth writing both orders once to see the difference.
Constraints - `0 ≤ n ≤ 1000000000000000000`
Input
A single line containing one integer n.
Output
Print the digits of n, one per line, in their original order.