fork download
  1. #define t(x,o)n<x?o:f(n/x)+(n%x?f(n%x):0)
  2. char*i="4335443554366887798866555766";f(n){return t(1000,t(100,n<20?n<0?8+f(-n):i[n]-48:i[n/10+18]-48+(n%10?f(n%10):0))+7)+8;}main(n){for(scanf("%d",&n);n^4;n=f(n))printf("%d is %d and ",n,f(n));puts("4 is the magic number");}
Success #stdin #stdout 0s 2164KB
stdin
1777
stdout
1777 is 35 and 35 is 10 and 10 is 3 and 3 is 5 and 5 is 4 and 4 is the magic number