# Find prime numbers with given property [closed]

I've been working in the following number theory problem: find all prime numbers $$p,q,r$$ such that $$p^2+q^2+r^2-1$$ is a perfect square. Does anyone has some hint for the problem? Thanks in advance.

• What have you tried? What properties of square numbers do you know which might be helpful. Have you found any solutions? – Mark Bennet May 8 at 10:47
• The triple $p=q=2$, $r=3$ is a solution. – Cl132 May 8 at 11:05
• You have a couple of answers now, Cl. If one of them suits you, you can "accept" it by clicking in the check mark next to it. If neither one suits you, you can leave a comment explaining what more you need. – Gerry Myerson May 9 at 13:11

## 2 Answers

Note that if $$n$$ is an odd integer, then $$n^2\equiv1\pmod8$$, and if $$n$$ is an even number, then $$n^2\equiv0\pmod 4$$.

If $$p,q,r$$ are all odd primes, then $$p^2+q^2+r^2-1\equiv2\pmod8$$, so it can't be a square. So we may assume $$p=2$$, and we have $$q^2+r^2+3$$.

Now if $$q,r$$ are both odd, then $$q^2+r^2+3\equiv5\pmod8$$, so it's not a square. So we may assume $$q=2$$, and we have $$r^2+7$$.

If $$r^2+7=m^2$$, then $$7=m^2-r^2$$, but there is only one way to write $$7$$ as a difference of two squares, namely, $$7=4^2-3^2$$. So $$r=3$$, and we're done.

• I held off too long posting my version of this - just to comment that $(2m+1)^2 =8\cdot \frac {m(m+1)}2$ for OP's sake (this works as a proof too) and also that working modulo $8$ is often a good thing to do when problems about squares involve parity issues. – Mark Bennet May 8 at 11:41
• Also "only one way to write $7$" comes easily from $m^2-r^2=(m+r)(m-r)$ and $7$ is a prime so $m+r=7, m-r=1$. – Mark Bennet May 8 at 11:45
• This question seems not to meet the standards for the site. Instead of answering it, why not look for a good duplicate target, or help the user by posting comments suggesting improvements? Please also read the meta announcement regarding quality standards. – amWhy May 9 at 15:54
• Trivial edit made Gerry, to undownvote, as I did not dv the other answer. But please consider how you can find a way to work with the meta announcement? In particular, you are well known for your commenting skills! Anyway, Cheers. – amWhy May 9 at 21:11

The triple $$p=q=2, r = 3$$ is the only possible solution (up to reordering). To show this first reduce the expression modulo $$4$$. Since a square must always be congruent to $$0$$ or $$1$$ mod $$4$$ we get $$p^2+q^2+r^2 \equiv 1 \pmod{4} \quad \text{or} \quad p^2+q^2+r^2 \equiv 2 \pmod{4}.$$ Since any odd number squares to $$1 \pmod{4}$$ we may assume $$p = 2$$. Hence we need to find all primes $$q,r$$ such that $$r^2+q^2+3$$ is a square. Now reduce the equation mod $$3$$ to find $$r^2 + q^2 \equiv 0 \pmod{3} \quad \text{or} \quad r^2 + q^2 \equiv 1 \pmod{3},$$ since $$0$$ and $$1$$ are the only quadratic residues modulo $$3$$. Therefore at least one of $$q$$ or $$r$$ must be divisible by $$3$$. Since we assume them to be prime this forces without loss of generality $$r = 3$$. Finally we look for primes $$q$$ such that $$q^2 + 12$$ is a square. The quadratic residues modulo $$8$$ are $$0,1,4$$. Reducing mod $$8$$ therefore gives $$q^2 \equiv 4 \pmod{8} \quad \text{or} \quad q^2 \equiv 5 \pmod{8} \quad \text{or} \quad q^2 \equiv 0 \pmod{8}.$$ Since $$5$$ is a non-residue we must have $$q^2 \equiv 0 \pmod{8}$$ or $$q^2 \equiv 4 \pmod{8}$$. In either case $$q$$ must be even. Since we assumed it to be prime it follows $$q=2$$.

• When you say "The only possible solution" don't forget that any one of the three primes can be the one equal to $3$ with the others equal to $3$ - three solutions as posed. – Mark Bennet May 8 at 11:26
• I suppose that's true, I'll add an 'up to reordering' - thanks :) – Leo May 8 at 11:27
• Two details: You have a typo ($r^2+q^3+3$), and $-1$ is not a quadratic residue modulo $8$ – jjagmath May 8 at 11:33
• Whoops, I made the changes - thanks. – Leo May 8 at 11:36
• This question seems not to meet the standards for the site. Instead of answering it, why not look for a good duplicate target, or help the user by posting comments suggesting improvements? Please also read the meta announcement regarding quality standards. – amWhy May 9 at 15:55