1

If I have this:

  • $x \pmod p = 1$
  • $x \pmod q = 0$

Is there any way I can find a possible natural number for $x$ that satisfies both equations. I know it has something to do with the Chinese Reminder Theorem; however, I have been unable to solve it.

Jyrki Lahtonen
  • 133,153

3 Answers3

0

No need for the Chinese Remainder Theorem.

I'll assume you intended to require $p,q$ to be relatively prime positive integers.

Then by Bezout's Theorem, there exist integers $a,b$ such that $$ap+bq=1$$ If $p,q$ are given, qualifying values of $a,b$ can be found via the Extended Euclidean Algorithm.

Moreover, if $(a,b)$ is any qualifying pair, so is $(a',b')=(a-qt,b+pt)$, for any integer $t$.

Hence, by choosing $t$ appropriately, we can force $b' > 0$.

Thus, we can get $$a'p+b'q=1$$ with $b' > 0$.

Then letting $x=b'q$, it follows that $x$ is a positive integer such that \begin{align*} x&\equiv 1\;(\text{mod}\;p)\\[4pt] x&\equiv 0\;(\text{mod}\;q)\\[4pt] \end{align*}

quasi
  • 58,772
0

$x\equiv 0\pmod{\!q}\!\iff\! q\mid x\!\iff\! x = qn,\ $ so $\bmod p\!:\ qn = x\equiv 1\!\iff\!\!\!\!\!\!\!\!\!\overbrace{ n\equiv q^{-1}}^{\large{\rm exists} \iff (q,p)=1}$

If so $\, x \equiv q(q^{-1}\bmod p)\, \pmod{\! pq}.\,$ Inverses van be computed via Extended Euclidean algorithm

It's a special case of CRT = Chinese Remainder Theorem (but we don't need that generality here)

Bill Dubuque
  • 272,048
-1

Hint: If you mod something by P and Q, what kind of number gives a result as a 1 or 0? think of Odd's and Even's.