Consider a counter that counts from 0 to 9.
0 → 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9
As an extension of this counter, we considered a counter that can start with any number.
2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 0 → 1 (Example starting from 2, the counter returns to 0 when it reaches 9.)
Receive the number n from the input, start the counter from n,
Implement a program that outputs 10 counter values in order.
The input is given in the following format
n
・ N is the first value of the counter
Output the 10 counter values starting with n in order, separated by line breaks.
0
0 1 2 3 4 5 6 7 8 9
2
2 3 4 5 6 7 8 9 0 1
python
n = 2
#Reset to 0 when n reaches 10, pass otherwise and output 10
for i in n..9 do
if n == 9
n = 0
puts i
n += 1
end
end
Recommended Posts