# Quadratic equation $x^2-ax+2a = 0$ with Integers Roots

Find Integer value of $a$ for which both roots of the equation $x^2-ax+2a = 0$ are also integers

My Try:: $\displaystyle x = \frac{a \pm \sqrt{a^2-8a}}{2}$. Now if the Roots are Integer . Then $a^2-8a=k^2$ where $k\in \mathbb{Z}$

Now How can I calculate after that., Thanks

-
If $a^2-8a=k^2$ then, completing the square, we get $a^2-8a+16=k^2+16$ and $(a-4)^2=k^2+16$, so $b^2-k^2=16$ (where $b=a-4$). What is known about Pell-like equations that would apply here? – Michael Hardy Feb 27 '13 at 17:04

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$.
How about $k = 3$? – Andreas Caranti Feb 27 '13 at 16:58