# Find the largest integer $n$ such that $n^2$ is the difference of two consecutive cubes and $2n +79$ is a perfect square.

Find the largest integer $n$ such that $n^2$ is the difference of two consecutive cubes and $2n +79$ is a perfect square.

This is an AIME problem. I have been trying and have been going round in circles.

First of all, let the smaller cube be $k$. Difference in cubes $= 3k^2 + 3k +1 = 3k(k+1) + 1=n^2$. It's clear that this $n$ is always odd.

So,

$$2\sqrt{3k(k+1)+1}+79=m^2$$ Solving this, we get: $$3k(k+1) = \frac{(m^2-81)(m^2-77)}{4}$$

or

$$3k(k+1)+1 = \frac{(m^2-81)^2 + 4(m^2-81)+4}{4}$$

I feel that I'm getting nowhere near the solution.

Can you please give me some hints on how to proceed. Thanks.

• I would spend a while solving $3k^2+3k+1=n^2$. It is a Pellian equation, or very nearly. Then go on to the $m^2$ part. – Empy2 Mar 25 '16 at 16:49
• @Michael How? $$– TheRandomGuy Mar 25 '16 at 16:51 • Please, before asking on Stackexchange, look on the web if the solution is accessible. It has needed me some seconds to find artofproblemsolving.com/wiki/… – Jean Marie Mar 25 '16 at 16:52 • @JeanMarie There is still value for StackExchange if questions that are answered elsewhere are also answered here – Peter Woolfitt Mar 25 '16 at 16:53 • @Peter Woolfitt I partly agree with you. – Jean Marie Mar 25 '16 at 16:59 ## 1 Answer Let$$n^2 = (m + 1)^3 - m^3 = 3m^2 + 3m + 1$$Note that$$(2n + 1)(2n - 1) = 4n^2 - 1 = 12m^2 + 12m + 3 = 3(2m + 1)^2$$Since$$\gcd(2n-1,2n+1)=1

Since their product is three times a square, one of them must be a square and the other three times a square. If we have $2n - 1=3a^2$, then $2n + 1=b^2=3a^2+2 \equiv 2 \pmod 3$ which is impossible since $2$ is a quadratic non-residue of $3$.

Thus $2n - 1$ is a square, let this be $b^2$. But since $2n + 79$ is also a square, say $a^2$. Then $(a + b)(a - b) = a^2 - b^2 = 80$.

Since $a + b$ and $a - b$ have the same parity and their product is even, they are both even.

To find the largest value of $n$, it suffices to maximize $2b$, which is $(a + b) - (a - b)$.

However , it is not difficult to see this occurs when $a + b = 40$ and $a - b = 2$, that is, when $a = 21$ and $b = 19$. This yields $n = 181$ and $m = 104$, so the answer is $181$.