You are given two positive integers A and B. An equation is given,
Z = P*A + Q*B.
Where P and Q can be any integers, while A and B are the given integers.
If you replace P and Q with appropriate values, find the minimum positive value that Z can achieve through the equation.
Note: Your solution will run on multiple test cases so do clear global variables after using them.
A: Integer B: Integer
Minimum positive value of Z
1 <= A, B <= 10^9 Z has to be the minimum positive value P, Q can be any integers (positive, negative, or zero)
A: 2 B: 3
1 Z = P*A + Q*B, Z = P*2 + Q*3, Let P = 2, and Q = -1, we get Z = 2*2 + -1*3 Z = 4 - 3 Z = 1 Hence minimum positive value of Z is 1.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.