Recursive sum of digits of a number is prime or not | Function for recursive digit sum ; Function to check if prime or not the single digit ; Calls function which returns sum till single digit ; Checking prime ; Driver code
function recDigSum ( n ) { if ( n == 0 ) return 0 ; else { if ( n % 9 == 0 ) return 9 ; else return n % 9 ; } } function check ( n ) { n = recDigSum ( n ) ; if ( n == 2 n == 3 n == 5 n == 7 ) document . write ( " " ) ; else document . write ( " " ) ; } let n = 5602 ; check ( n ) ;