Recursive sum of digits of a number formed by repeated appends | return single digit sum of a number . ; Returns recursive sum of digits of a number formed by repeating a number X number of times until sum become single digit . ; Driver Code
< ? php function digSum ( $ n ) { if ( $ n == 0 ) return 0 ; return ( $ n % 9 == 0 ) ? 9 : ( $ n % 9 ) ; } function repeatedNumberSum ( $ n , $ x ) { $ sum = $ x * digSum ( $ n ) ; return digSum ( $ sum ) ; } $ n = 24 ; $ x = 3 ; echo repeatedNumberSum ( $ n , $ x ) ; ? >