GCD of two numbers formed by n repeating x and y times | Return the Greatest common Divisor of two numbers . ; Prints Greatest Common Divisor of number formed by n repeating x times and y times . ; Finding GCD of x and y . ; Print n , g times . ; Driven Program
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function findgcd ( n , x , y ) { let g = gcd ( x , y ) ; for ( let i = 0 ; i < g ; i ++ ) document . write ( n ) ; } let n = 123 , x = 5 , y = 2 ; findgcd ( n , x , y ) ;