Reverse an integer without using string operations.
Utilisateur anonyme
I give up on copy/pasting code. Keeps mangling it. The basic idea is a while statement with orig > 10. Inside of loop add (mod 10 of orig) to reversed. multiply reversed by 10, divide orig by 10. Last digit will be after exiting loop. Just add remaining orig to reversed. There is an extra check for a negative number. Really easy once you figure out the mod 10 idea.