Minimum positive integer value possible of X for given A and B in X = P * A + Q * B | CPP Program to find minimum value of X in equation X = P * A + Q * B ; Utility function to calculate GCD ; 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 ) ; } int main ( ) { int a = 2 ; int b = 4 ; cout << gcd ( a , b ) ; return 0 ; }