/*Program to find the nummber of applications of sqn function needed to reach 1 or 89 for a given number. sqn function applied on a function returns the sum of squares of digits of a number*/ #include int sqn(int);//Prototype for sqn int main() { int n,tmp,depth=0; scanf("%d",&n); tmp = n; while(tmp!=1 && tmp!=89) { tmp = sqn(tmp); depth++; } printf("Depth of %d is %d\n",n,depth); return 0; } int sqn(int m) { int result=0,digit; while(m > 0) { digit = m%10; result += digit*digit; m = m/10; } return result; }