Reverse an Integer
A stock room inherited a batch of old shelf labels on which the serial number was printed back to front. Staff type in the number as it appears on the new system and the tool shows the number the way the old label reads. The result is a number, so any zeros that end up at the front are simply not written.
Task: Read the serial number and print its digits in the opposite order, as a number.
Input
A single line holding one non-negative integer of 1 to 18 digits. There is no sign and no leading zeros.
Output
One line holding a single integer: the same digits in the opposite order, written without leading zeros. The number 0 prints as 0.
Example:
Input:
1200
Output:
21
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in