Number of integral solutions for equation x = b * ( sumofdigits ( x ) ^ a ) + c | This function returns the sum of the digits of a number ; This function creates the array of valid numbers ; this computes s ( x ) ^ a ; this gives the result of equation ; checking if the sum same as i ; counter to keep track of numbers ; resultant array ; prints the number ; Driver Code ; calculate which value of x are possible
< ? php function getsum ( $ a ) { $ r = 0 ; $ sum = 0 ; while ( $ a > 0 ) { $ r = $ a % 10 ; $ sum = $ sum + $ r ; $ a = ( int ) ( $ a / 10 ) ; } return $ sum ; } function value ( $ a , $ b , $ c ) { $ co = 0 ; $ p = 0 ; $ no ; $ r = 0 ; $ x = 0 ; $ q = 0 ; $ w = 0 ; $ v = array ( ) ; $ u = 0 ; for ( $ i = 1 ; $ i < 82 ; $ i ++ ) { $ no = pow ( $ i , $ a ) ; $ no = $ b * $ no + $ c ; if ( $ no > 0 && $ no < 1000000000 ) { $ x = getsum ( $ no ) ; if ( $ x == $ i ) { $ q ++ ; $ v [ $ u ++ ] = $ no ; $ w ++ ; } } } for ( $ i = 0 ; $ i < $ u ; $ i ++ ) { echo $ v [ $ i ] . " " ; } } $ a = 2 ; $ b = 2 ; $ c = -1 ; value ( $ a , $ b , $ c ) ; ? >