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

How to find all natural $x$ for that $x^2 + (x+1)^2$ is a perfect square?

share|cite|improve this question
up vote 12 down vote accepted

Suppose $x^2 + (x+1)^2 = y^2$. We can rewrite it as $(2x+1)^2 + 1 = 2y^2$ or $(2x+1)^2 - 2y^2 = -1$.

If $z=2x+1$ then we have $z^2 - 2y^2 = -1$. This is Pell's equation. Wikipedia article shows how to solve it.

share|cite|improve this answer
In particular, because the smallest solution of z²-2y²=-1 is (1,1), all solutions are given by writing (1+√2)^n = z + y√2, for odd n. For instance (1+√2)³ = (7+5√2). So solutions (z,y) are (1,1), (7,5), (41,29), (239,169), (1393,985) and so on, corresponding to x = 0, 3, 20, 119, 696, … – ShreevatsaR Jul 29 '10 at 7:50

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.