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 was doing some work on prime numbers, and I came across this problem:

"For prime numbers $p$ and $q$, determine the greatest prime, $r$ less than $100$ for which $r = p^2 + q^2$." Of course, you can always do it by hand, but I was wondering, are there were any faster methods to solving it?

Thanks for any help.

share|cite|improve this question
I find the question not very well written. My answer to it would be “Well, it’s obviously p^2+q^2 if it is a prime number” as you fix p and q beforehand. I would suggest “Find the greatest prime r < 100 such that $r = p^2+q^2$ for some prime numbers p and q. – Édouard Feb 26 at 9:18
@Édouard: Yes - or better still "... $r < 100$ that can be expressed as ..." :) – psmears Feb 26 at 10:53

Note that if $p$ and $q$ are odd, then $p^2$ and $q^2$ are also. Then $p^2+q^2$ is even and can't be prime ($2$ can't be written as such a sum). Then necessarily $$r=4+q^2$$ With $r$ less than $100$ the only possible values for $q$ are the primes up to $10$.

share|cite|improve this answer
And if you start with the largest such prime first... – gnasher729 Feb 26 at 10:52

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.