how many solution can be found of the form $A \pmod{X} = B$

39 Views Asked by At

$A$ and $B$ are given, How many $X$ can be found to make the following equation true? $$ A \pmod{X} = B $$ Is there any formula?

1

There are 1 best solutions below

0
On

Assuming that $A,B\in\mathbb{N}$, without loss of generality let $A\geq B$. Consider the prime factorization of $A-B$.

$(A-B) = 2^{p_1}\cdot 3^{p_2} \cdot 5^{p_3} \cdot 7^{p_4}\cdot\dots\cdot \pi_n^{p_n}$

Any combination of products powers of primes, $\pi_i$ with power at most $p_i$ will satisfy the equation.

As such, the number of $X$'s that satisfy the equation $A \mod X = B$ is $\Pi_{i=1}^n (p_i+1)$

Example 1: $A= 37$, $B=5$, $A-B = 32 = 2^5$

So, there are 6 choices. $X=1$ gives modulo equal to 0, $X=2, 4$ has both modulo equal to 1, and $X= 8, 16, 32$ has both modulo equal to 5.

Example 2: $A= 38$, $B=18$, $A-B = 20 = 2^2\cdot 5^1$

So, there are 6 choices. $X=1 , 2$ each give modulo equal to 0 $X = 4$ gives modulo equal to 2, $X= 5$ gives modulo equal to 3, $X=10$ gives modulo equal to 8