Find the ratio of number of elements in two Arrays from their individual and combined average | Java program to Find the Ratio of number of Elements in two Arrays from their individual and combined Average ; function to find the ratio of number of array elements ; calculating GCD of them ; make neumarator and denominator coprime ; Driver Code
class GFG { static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } static void FindRatio ( int a , int b , int c ) { int up = Math . abs ( b - c ) ; int down = Math . abs ( c - a ) ; int g = gcd ( up , down ) ; up /= g ; down /= g ; System . out . println ( up + " : " + down ) ; } public static void main ( String [ ] args ) { int a = 4 , b = 10 , c = 6 ; FindRatio ( a , b , c ) ; } }