I am trying to solve a algorithmic problem, which has a sub-part which asks you to find an integer m such that for given two integers a and b, we get a mod m = b mod m. mod is the modulo operation. How to approach this problem?
a mod m = b mod m
==> (a - b) mod m = 0
==> (a-b) = k * m for some integer k
==> (a-b) / m = k
So m
can be any factor of a-b
.