I found an interesting problem on https://www.codewars.com/kata/58069e4cf3c13ef3a6000168:
Impliment the reverse function, which takes in input n and reverses it. For instance, `reverse(123)` should return `321`. You should do this without converting the inputted number into a string.

I tried it in Python, but could not do it. Can you solve it?
def reverse(n):
    m = 0
    while n > 0:
        n, m = n // 10, m * 10 + n % 10
    return m