Skip to main content
1 of 2
gastropner
  • 4.4k
  • 1
  • 15
  • 20

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;}

Try it online!

gastropner
  • 4.4k
  • 1
  • 15
  • 20