Consider the problem of finding all values of $ n \in \mathbb{N}$ s.t. $ $ \sqrt{n} + \sqrt{n + 2005}$ $

is an integer.

One can easily verify that $ n = 1,004,004$ and $ 39,204$ satisfy this requirement, and in fact are the only such solution values for $ n$ . The simplest approach is to set the right hand side to some variable $ m \in \mathbb{Z}$ , square both sides, manipulate and note the prime factorization of $ 2005$ … that is, $ 2005 = 2005 \cdot 1 = 401 \cdot 5$ and equate factors.

I would like to compute the solution directly, however.

The natural approaches do not work:

`Solve[ Sqrt[n] + Sqrt[n + 2005] == m, {n, m}, Integers] `

and

`FindInstance[ Sqrt[n] + Sqrt[n + 2005] == m , {n, m}, Integers] `

and

`Assuming[{n, m} \[Element] Integers, Solve[Sqrt[n] + Sqrt[n + 2005] == m, {n, m}]] `

I’ve tried a number of minor variations, adding constraints such as $ \{ n, m \} > 0$ , and so forth. None work.

As yarchik shows (below), one can solve this with the result from number theory that each of the component square roots must resolve to an integer (demonstrated here). That leads to two questions:

- What would we do if we didn’t know that fact from number theory?
- Supposing we do know that fact from number theory. How would we programmatically impose it as some form of constraint or subsidiary equation rather than "by hand"?

Suggestions?