FastPrepFastPrep
Problem Brief

Give Minimum Sum

OA

Give the minimum sum of (x+y) such that A and B are given and (A+x) should be multiple of (B+y).

1Example 1

Input
A = 8, B = 16
Output
0
Explanation
Educated guess - Since A is already a multiple of B, no additional sum is needed. Therefore, the answer is 0.

2Example 2

Input
A = 7, B = 37
Output
4
Explanation
Educated 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

Limits and guarantees your solution can rely on.

๐ŸŠ๐ŸŠ
public int giveMinimumSum(int A, int B) {
  // write your code here
}
Input

A

8

B

16

Output

0

Sign in to submit your solution.