Problem 196002 · easy · Phase 01 Prerequisites & Setup

Reverse the Digits

loops · while · digits · modulo

Write reverse_number(n) that returns the integer whose digits are those of n in reverse order. Leading zeros disappear naturally because the result is an integer. Use arithmetic and a loop, not string slicing.

Examples

Input:  n = 1230
Output: 321

Input:  n = 45
Output: 54

Constraints

  • 0 <= n <= 10**18

Goals

  • Extract the last digit with % 10
  • Build a new number digit by digit
Starting Python…