Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking at this problem and I am confused on how one could easily compute this. Is it just the intersection of either non-quadratic residue or quadratic residues of the respective p and q?

share|cite|improve this question
What is the question again? – Jyrki Lahtonen Mar 26 '12 at 19:51
up vote 1 down vote accepted

Firstly the case $i=j=1$ is simple since the number $1$ will do this.

Secondly when $i = -1$ and $j=1$ we can use the number $-1$ since this is a QR mod $p'$ (prime) if and only if $p'\equiv 1$ mod $4$.

Thirdly when $i=j=-1$ we can use the number $2$ since this is a QR mod $p'$ if and only if $p\equiv 1,7$ mod $8$.

For the final case we may use $-2$ since we can see that the product of the $i,j$ values in the previous two cases match what we want (essentially we are using the homomorphism property of Legendre symbols here).

share|cite|improve this answer
Hi fretty, why is mod 8 or mod 4 used or derived from? Thanks – user27617 Mar 26 '12 at 15:09
These are the simple rules about when $-1$ or $2$ are QR's mod $p$ – fretty Mar 26 '12 at 18:09
Sorry. I have problems parsing this. What are the variables $i$ and $j$? Where did they come from? – Jyrki Lahtonen Mar 26 '12 at 19:50
The question seems to have been edited! – fretty Mar 26 '12 at 21:12

If you want to find $x$ such that it is a QR mod p and a NR mod q for example, you can just find a QR mod p (say m), find a NR mod q(say n), then use Chinese remainder theorem to solve

$$\begin{cases}x \equiv m & (\operatorname{mod} p) \\ x \equiv n & (\operatorname{mod} q) \end{cases}$$

share|cite|improve this answer
Hi user27126, could you please provide an example for say i=1 and j=-1. I am not sure how the CR theorem can help here. Thank you. – user27617 Mar 26 '12 at 13:59
Let's take $m = 0$, $n = 2$. You want to find x = 0 (mod 19), x = 2 (mod 37). Just use chinese remainder theorem to solve this congruence. – user27126 Mar 26 '12 at 17:08

The solution by user27126 is fine, but you can cut a few corners. For example, there is one kind of number $n$ that is guaranteed to be a quadratic residue mod $p$ for all $p$ not dividing $n$ - do you know what I'm referring to? Also, you should know when $-1$ is a residue, that should settle another case without any need to resort to Chinese remainders. If you know when 2 is a residue, there goes another case. And so on.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.