Minimum positive integer value possible of X for given A and B in X = P * A + Q * B | Java Program to find minimum value of X in equation X = P * A + Q * B ; utility function to calculate gcd ; Driver Program
import java . util . * ; import java . lang . * ; class GFG { public static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } public static void main ( String [ ] args ) { int a = 2 ; int b = 4 ; System . out . println ( gcd ( a , b ) ) ; } }