Program to find the common ratio of three numbers | Utility function ; Function to print a : b : c ; To print the given proportion in simplest form . ; Get the ratios ; Get ratio a : b1 ; Get ratio b2 : c ; Find the ratio a : b : c
function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } function solveProportion ( a , b1 , b2 , c ) { let A = a * b2 ; let B = b1 * b2 ; let C = b1 * c ; let gcd = __gcd ( __gcd ( A , B ) , C ) ; document . write ( A / gcd + " " + B / gcd + " " + C / gcd ) ; } let a , b1 , b2 , c ; a = 3 ; b1 = 4 ; b2 = 8 ; c = 9 ; solveProportion ( a , b1 , b2 , c ) ;