GCD of a number raised to some power and another number | PHP program to find GCD of a ^ n and b ; Returns GCD of a ^ n and b . ; Driver code
< ? php function gcd ( $ a , $ b ) { if ( $ a == 0 ) return $ b ; return gcd ( $ b % $ a , $ a ) ; } function powGCD ( $ a , $ n , $ b ) { for ( $ i = 0 ; $ i < $ n ; $ i ++ ) $ a = $ a * $ a ; return gcd ( $ a , $ b ) ; } $ a = 10 ; $ b = 5 ; $ n = 2 ; echo powGCD ( $ a , $ n , $ b ) ; ? >