Divide the two given numbers by their common divisors | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } void commDiv ( int a , int b ) { int n = gcd ( a , b ) ; a = a / n ; b = b / n ; cout << " A ▁ = ▁ " << a << " , ▁ B ▁ = ▁ " << b << endl ; } int main ( ) { int a = 10 , b = 15 ; commDiv ( a , b ) ; return 0 ; }