How to reverse digits of an integer mathematically? Is there a mathematical way to reverse digits of an integer mathematically? for example:
 $18539 \rightarrow 93581$ 
 A: Here's a recursive formula:
$$R(N)=U(N)10^{[log(N)]}+R([N/10])$$
where
$$U(N)=N-10[N/10]$$
is the "unit" digit of $N$ (i.e., the digit in the "ones" column), and $R(0)$ is understood to equal $0$.  The logarithm is base $10$, and the square brackets indicate the greatest-integer (floor) function.
Note:  reversing digits is not an involution when $U(N)=0$.  E.g., $R(100)=1$, but R($1)\neq100$.
Added later:  It occurs to me that the recursive formula adapts nicely to digit reversal in any base:
$$R_b(N) = U_b(N)b^{[log_b(N)]}+R_b([N/b])$$
where
$$U_b(N)=N-b[N/b]$$
A: let number be 123. 
perform 123%10 = 3 = a
perform 123/10 =12
if not 0,then multiply a with 10, so a = 30 
perform 12%10 = b 
perform 12/10 = 1
if not 0, then multiply b with 10 & a with 10,so a = 300 & b = 20
perform 1%10 = c 
perform 1/10 = 0
if not 0, continue....however, as this is 0, you stop the process.
just add a+b+c. = 300+20+1 = 321

& in terms of pure mathematics:
sum of [{floor of n/10^(N-1-k)}*{10^k] for k= 0 to N-1. where n is integer, & N is no of digits.
