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