Find the ratio of number of elements in two Arrays from their individual and combined average | Javascript function to find the ratio of number of array elements ; calculating GCD of them ; make neumarator and denominator coprime ; Driver Code
function FindRatio ( a , b , c ) { let up = Math . abs ( b - c ) ; let down = Math . abs ( c - a ) ; let g = gcd ( up , down ) ; up = parseInt ( up / g ) ; down = parseInt ( down / g ) ; document . write ( up + " " + down + " " ) ; } function gcd ( a , b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } let a = 4 , b = 10 , c = 6 ; FindRatio ( a , b , c ) ;