Given a, b How many solutions exists for x, such that: $a \bmod{x}=b $

89 Views Asked by At

Given $a, b$. How many solutions exists for $x$, such that: $$a \bmod{x}=b $$

By example:

$a = 21$ and $b = 5$

$21 \bmod{8} = 21 \bmod{16} = 5$

Then $x$ has 2 solutions

1

There are 1 best solutions below

7
On

If I understand your question correctly, consider that $a \equiv b \pmod x$ if and only if $a-b = kx$ for some $k\in\mathbb{Z^+}$. Then $x=\frac{a-b}{k}$, hence there is precisely one $x$ for each divisor $k\in\mathbb{Z^+}$.