Reverse a Number
Completed
Read a positive integer and print its digits reversed as a number (leading zeros disappear), using arithmetic only.
Input
One integer ≥ 1.
Output
The reversed number.
Example
Input
1234
Output
4321
Editor
Python
Hints
Take the last digit with n % 10 and append it to rev with rev * 10 + digit.
Solution explanation
Shifting rev left (×10) and n right (//10) moves one digit per step.
Show solution
n = int(input())
rev = 0
while n > 0:
rev = rev * 10 + n % 10
n //= 10
print(rev)