C (gcc), 77 bytes
Has to be compiled with the -lm
switch or GCC doesn't recognize the math functions.
r,q,i;f(n){for(r=0,i=n;i;i/=10)q=(log10(n)+1)-i%10,r+=n/pow(10,q>0?q:0);n=r;}
Has to be compiled with the -lm
switch or GCC doesn't recognize the math functions.
r,q,i;f(n){for(r=0,i=n;i;i/=10)q=(log10(n)+1)-i%10,r+=n/pow(10,q>0?q:0);n=r;}