text: Check if the sum of digits of a number N divides it | Function to check if sum of digits of a number divides it ; Calculate sum of all of digits of N ; Driver Code
code: function isSumDivides ( N ) { var temp = N ; var sum = 0 ; while ( temp > 0 ) { sum += temp % 10 ; temp = parseInt ( temp / 10 ) ; } if ( N % sum == 0 ) return 1 ; else return 0 ; } var N = 12 ; if ( isSumDivides ( N ) == 1 ) document . write ( " " ) ; else document . write ( " " ) ;