Lets put an example. Let's say you input the number 5741, here's how it is processed:

5741

lastDigit = 5741 % 10
lastDigit = 1

reverse = 0*10 + 1
reverse = 1