I was in a math contest the other day and this was the last question:

Find all $n\in \Bbb N$ for which $n^2+77n$ is a square of some natural number.

I only got this far:

Since $n^2+77n=n(n+77)$, I figured that this could be divided up into three separate cases:

1) $n=n+77$ (this has no solutions);

2) $n=a^2$ and $n+77=b^2$ for some $a,b\in \Bbb N$ (the only solution I managed to find by hand was $n=4$, but couldn't prove there weren't more);

3) $n$ and $n+77$ share some prime factors and in both numbers those prime factors have an odd power (if $n$ has a prime factor of $p^{2l-1}, l\in \Bbb N$, then $n+77$ should have a prime factor of $p^{2k-1}, k\in \Bbb N$).

This didn't seem like a very easy thing to solve/prove, so I continued searching:

$$n^2+77n=a^2, a\in \Bbb N$$ $$n^2+77-a^2=0$$ $$n_1=\dfrac {-77+\sqrt{77^2+4a^2}} 2$$ $$n_2=\dfrac {-77-\sqrt{77^2+4a^2}} 2$$ We have to only consider $n_1$, since $n_2$ is always negative and we are searching for natural numbers. So, now we only need to find such $a$, for which $\sqrt{4a^2+5929}$ is a natural number. No idea how to do that.

This was the point at which I had no idea what to do and just gave up. Any help would be appreciated.

  • $\begingroup$ $n=4$ is one solution $\endgroup$ Commented Jan 29, 2017 at 10:03

2 Answers 2


Good job so far (the splitting into cases in particular). Because it sounds like you want to continue working on this let me give just a few hints that allow you to make further progress.

  • For your case 2: If $n=a^2$ and $n+77=b^2$, then $$7\cdot11=77=(n+77)-n=b^2-a^2=(b-a)(b+a).$$ What choices are there for $b\pm a$? Don't forget the possibility of trivial factors!
  • For your case 3: If a prime $p$ divides both $n$ and $n+77$, then $p$ also divides their difference ... Anyway, you have possibilities like $n=pa^2$, $n+77=pb^2$. The technique for studying the second case can be reused.
  • $\begingroup$ Thank you! I managed to get another solution ($n=38^2=1444$) from case 2, but I don't yet understand how I could use the method for case 3... $\endgroup$
    – DDomjosa
    Commented Jan 29, 2017 at 10:15
  • $\begingroup$ Good @DDomjosa ! You should be able to infer that either $p=7$ or $p=11$. If $p=7$, then you get $n=7a^2$ and $n+77=7b^2$. This gives you $$77=7(b-a)(b+a),$$ or $11=(b-a)(b+a)$ and one more solution. The case $n=11a^2$, $n+77=11b^2$ gives yet another solution. $\endgroup$ Commented Jan 29, 2017 at 12:19

Here is a standard approach to this sort of question.

You want: $$n^2+77n=y^2$$

After completing the square, you get $$(2n+77)^2 = 4y^2+77^2$$

or $(2n+77-2y)(2n+77+2y)=77^2$.

(Note that this is saying that $4y^2+77^2$ is a perfect square, which is what you asked.)

So you need to factor $77^2$ into two numbers that differ by a multiple of $4$. But the multiple of $4$ condition is redundant here (why?) so each factoring of $77^2$ gives a different integer solution.

For example, $77^2=7^2\cdot 11^2$ means that $2n+77+2y=121, 2n+77-2y=49$ or $y=18, n=4$.

Given any $ab=77^2$ with $a\leq b$ you get $n=\frac{a+b-2\cdot 77}{4}$. You might require $a<b$ depending on whether your definition of $\mathbb N$ includes $0$ or not.

There are five $(a,b)$ pairs with $a\leq b$: $(1,77^2),(7,7\cdot 11^2),(11,7^2\cdot 11), (7^2,11^2),(77,77)$ given $n=1444,175,99,4,0$.

This generalizes to the case of when $n(n+D)$ is a perfect square. If $D$ is odd, you get that:

$$(2n+D)^2=4n(n+D)+D^2=4y^2+D^2$$ or $$D^2=(2n+D-2y)(2n+D+2y)$$

So any factorization $D^2=ab$ with $a\leq b$ gives $n= \frac{a+b-2D}{4}$ as a solution.

For $D$ even, you get $\left(\frac D2\right)^2 = \left(n+\frac D2-y\right)\left(n+\frac D2+y\right)$ and you want $\left(\frac D2\right)^2=ab$ with $a\leq b$ and $a,b$ the same parity. Then $n=\frac{a+b-D}{2}$.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .