1

We let's equation:

$a+k \pmod{b+k} = 0$

For example:

$a = 153$; $b = 52$;

We are looking for the smallest $k$ giving solution

$153+k \pmod {52+k} = 0$

The correct result is $k=49$ becouse:

$153+49 \pmod {52+49} = 202 \pmod {101} = 0$

What is the quickest way to calculate $k$? I need a very quick way.

Aurelio
  • 479

1 Answers1

0

a-b (mod b+k) is also 0;

k is the (minimal divisor of a-b greater then b) - b

kotomord
  • 1,814