Find all solutions to $h \pm \sqrt{h^2 - 671} \in \mathbb{Z}$

Find, with proof, all values of $h$ so that $h + \sqrt{h^2 - 671}$ and $h - \sqrt{h^2 - 671}$ are both integers.

I found the two solutions $h=36$ and $h=336$ for these two equations, but I can't seem to justify why $h$ must be an integer. However, if I could, then one could easily see that $h=36$ and $h=336$ are the only possibilities using the following argument. Let $x=h+\sqrt{h^2 - 671}$ and $y = h-\sqrt{h^2 - 671}$. Then $(x-h)^2 = h^2 - 671$ so $x(x-2h) = -671$ and a similar equation is obtained for $y$. Since $671 = 1\cdot 671 = 61\cdot 11$, it follows that $\{x,2h-x\} \in \{\{11,61\}, \{1,671\}\}$ from which one can deduce that $h=36$ and $h=336$ are solutions.

Also, if $h$ were irrational, then how would one formally justify that the two given expressions in terms of h cannot be integers?


Solution 1:

Note that $$ x \text{ and } y \text{ are integers} \Longrightarrow x+y = 2h \text{ and } x-y=2\sqrt{h^2-671} \text{ are integers}. $$

Let $2h=k\in \mathbb{Z}$, we can simplify the last condition to $$ \sqrt{k^2-4\times671} = l \in \mathbb{Z}_{\geq 0} $$

I think the rest is not that difficult for you to complete.

Solution 2:

Note that $xy=671$ — without any $h$! This leaves you with only a few possibilities for $x,y$, and then must have $h=\frac{x+y}2$.