Divide the two given numbers by their common divisors | Function to calculate gcd of two numbers ; Function to calculate all common divisors of two given numbers a , b -- > input integer numbers ; find gcd of a , b ; Driver code
function gcd ( a , b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } function commDiv ( a , b ) { let n = gcd ( a , b ) ; a = parseInt ( a / n , 10 ) ; b = parseInt ( b / n , 10 ) ; document . write ( " " + a + " " + b ) ; } let a = 10 , b = 15 ; commDiv ( a , b ) ;