n=1e6,m,c,d;main(){while(c+=d==42,d=0,m=--n)while(d+=m%10,m/=10);printf("%d\n",c);}
Standard input is empty
6062
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!