Divide the two given numbers by their common divisors | Java implementation of above approach ; 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
class GFG { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static void commDiv ( int a , int b ) { int n = gcd ( a , b ) ; a = a / n ; b = b / n ; System . out . println ( " A ▁ = ▁ " + a + " , ▁ B ▁ = ▁ " + b ) ; } public static void main ( String [ ] args ) { int a = 10 , b = 15 ; commDiv ( a , b ) ; } }