Problem ยท Math
Give Minimum Sum
Learn this problemProblem statement
Give the minimum sum of (x+y) such that A and B are given and (A+x) should be multiple of (B+y).
Function
giveMinimumSum(A: int, B: int) โ intExamples
Example 1
A = 8B = 16return = 0Educated guess -
Since
A is already a multiple of B, no additional sum is needed. Therefore, the answer is 0.Example 2
A = 7B = 37return = 4Educated guess -
The minimum sum of
(x+y) to make (A+x) a multiple of (B+y) is 4. This can be achieved by setting x = 3 and y = 1, making (A+x) = 10 and (B+y) = 38, where 10 is a multiple of 38.Constraints
๐๐