GCD of a number raised to some power and another number | javascript program to find GCD of a ^ n and b . ; Returns GCD of a ^ n and b . ; Driver code
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 ) ; } var a = 10 , b = 5 , n = 2 ; document . write ( powGCD ( a , n , b ) ) ;