Minimum operations required to make two numbers equal | C ++ program to find minimum operations required to make two numbers equal ; Function to return the minimum operations required ; Keeping B always greater ; Reduce B such that gcd ( A , B ) becomes 1. ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; long long int minOperations ( long long int A , long long int B ) { if ( A > B ) swap ( A , B ) ; B = B / __gcd ( A , B ) ; return B - 1 ; } int main ( ) { long long int A = 7 , B = 15 ; cout << minOperations ( A , B ) << endl ; return 0 ; }