If both $n$ and $\sqrt{n^2+204n}$ are positive integers, find the maximum value of $n$.

I came across this question during a Math Olympiad Competition. I need help with solving the question. Thanks.

• All numbers are either of the form : $4k, 4k+1, 4k+2,4k+3$ and the squares of the numbers are always $4k, 4k+1$. $n^2+204n$ is a perfect square. Hence, it must be of the form $4k$ or $4k+1$ Now, try to solve for $n^2+204n \equiv 1 \mod 4$ and $n^2+204n \equiv 0 \mod 4$ or $n^2+204n-1 \equiv 0 \mod 4$ and $n(n+204) \equiv 0 \mod 4$ – MathMan Jun 3 '14 at 16:34

Let $$m^2=n^2+204n$$ $$k^2=n^2+204n+10404=(n+102)^2$$ Then $$(k-m)(k+m)=2^2\cdot 3^2\cdot 17^2$$ Since $k-m$ and $k+m$ have the same parity, they must be even. Write:

$$\frac{k-m}2\frac{k+m}2=3^2\cdot17^2$$

Since $k>m$ there are only two options: $k-m=2$ and $k-m=18$. The former gives $m=2600$ and the latter $m=280$. Thus we are interested in the former, which gives $n=2500$.

• How do you get to $$(k-m)(k+m)=2^2\cdot 3^2\cdot 17^2$$ ? as in how do you get the $$2^2\cdot 3^2\cdot 17^2$$? – snivysteel Jun 3 '14 at 16:46
• Substract the two fisrt equations to get $k^2-m^2=10404$, now factor $10404$ and $k^2-m^2$. – ajotatxe Jun 3 '14 at 16:50
• @ajotatxe How did you know to set k using: $$k^2=n^2+204n+10404=(n+102)^2$$ ... ? – KM. Jun 3 '14 at 18:33
• @KM. The idea came looking for what I needed to add to $n^2+204n$ to get a perfect square. – ajotatxe Jun 3 '14 at 18:50
• @KM. Complete the square. Since $204n=2 \times 102 \times n$ , we are interested in $102^2=10404$ to make the expression a perfect square. This might be done to generate a number in the R.H.S. while making use of the factorization $k^2-m^2=(k+m)(k-m)$ and then applying elementary number theory. – MathGod Jun 3 '14 at 18:50

there must be some natural $k$ s.t. $n^2 + 204n = (n+k)^2$. easy to see the bigger the $k$ the bigger the $n$ because it's equivalent to $$(204-2k)n = k^2$$ then again there's an easy bound on $k$ since $$n^2 + 204n < (n+102)^2$$ hence we can just try a couple of possibilities. if you write $$n^2 + 204n = (n+101)^2$$ then it won't give any solutions, since it boils down to $2n = 101^2$ on the other hand trying $$n^2 +204n = (n+100)^2$$ gives a solution $n=2500$ and we're done

So for some positive integer $m$, you must have $n^2+204n=m^2$. Considering this a quadratic in $n$, you need the discriminant $204^2+4m^2$ to be an even perfect square, say $4a^2$. So we have $a^2-m^2=10404 \implies (a+m)(a-m)=10404 \implies a+m = 5202, a-m=2$ as we want the largest $m$ (so as to get the largest $n$). Solving gives $m=2600 \implies n = 2500$.