One of the easiest way to do this is fooling the way around.
First convert the number into string. Then run a simple for loop to attain every character, and then finally convert them back to number at the time of allocation.
A simple code to the above algorithm is as shown below.
Please let me know in case of any doubts.