Find Integer value of $a$ for which both roots of the equation $x^2-ax+2a = 0$ are also integers.
My Try
$$x = \frac{a \pm \sqrt{a^2-8a}}{2}$$Now if the roots are integers, then $a^2-8a=k^2$, where $k\in \mathbb{Z}$.
Now How can I calculate after that? Thanks.
As you say, the question comes down to knowing when $a^2 - 8a - k^2 = 0$ for $k \in \mathbb{Z}$. Solving for $a$, $a = 4 \pm \sqrt{16 + k^2}$. As you can see, only for $k = 0$ or $k=3$ does this produce an integer solution for $a$ and so $a = 8$, $a = 0$, $a=9$ and $a=-1$ are possible.
The reason why those were the only $k$ values possible is because after a while, the difference between $k^2$ and $(k+1)^2$ is $2k+1$ and so when $k > 8$, $2k + 1$ becomes bigger than $16$. So we only need to test $k$ up to $8$.