Returns sum of squares of digits of a number n . For example for n = 12 it returns 1 + 4 = 5
int sumDigitSquare ( int n ) { int sq = 0 ; while ( n ) { int digit = n % 10 ; sq += digit * digit ; n = n / 10 ; } return sq ; }