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
< ? php 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 or $ n == 3 or $ n == 5 or $ n == 7 ) echo " Yes " ; else echo " No " ; } $ n = 5602 ; check ( $ n ) ; ? >