Conditions on $a,b\in\mathbb{Q}$, for $a+b\sqrt{n}$ to be integral over $\mathbb{Z}$ 
For $n\in \mathbb{Z}$ square-free, let $$k:=\mathbb{Q}(\sqrt{n}),$$ and
  let $$\alpha:=a+b \sqrt{n}\in k.$$ Prove that  $$ \alpha \mbox{
is integral over } \mathbb{Z}\;\;\; \Longleftrightarrow \;\;\;
\begin{cases} a,b \in \mathbb{Z}\\ \mbox{ or }\\ n\equiv 1 \mod 4,
\mbox{ and } a\equiv b \equiv \frac{1}{2} \mod\mathbb{Z}.\end{cases}$$

(Reid, Undergraduate Commutative Algebra, Problem 4.4)
To prove $\Leftarrow$, assuming first that $a,b\in \mathbb{Z}$, I claimed that $\alpha \in \mathbb{Z}[\sqrt{n}]$, which is an integral extension of $\mathbb{Z}$, and therefore $\alpha$ in also integral over $\mathbb{Z}$.
Can anyone help with the other implications ?
 A: $(\Longrightarrow)$: Suppose $\alpha = a + b \sqrt n$ is integral over $\mathbb Z$, then there exists $f \in \mathbb Z[x]$ such that $f(\alpha) = 0$. Suppose, without loss of generality, that $b \neq 0$. Notice that $$g(x) = x^2 - 2ax + (a^2 - b^2n)$$ has $\alpha$ as a root as well. By the division algorithm, there exist $q, r \in \mathbb Q[x]$ such that $f = q \cdot g + r$ with $r = 0$ or $\deg r < \deg g = 2$. If $\deg r < \deg g = 2$, then $r(x) = r_1 x + r_0$ where $r_1, r_0 \in \mathbb Q$. Notice that $$0 = f(\alpha) = q(\alpha) \cdot g(\alpha) + r_1\cdot \alpha + r_0 = r_1(a + b \sqrt n) + r_0 = (r_1\cdot a + r_0) + r_1b \sqrt n$$ which means that $r_1b = 0$ and $r_1\cdot a + r_0 = 0$, but the first part implies that $r_1 = 0$ (by definition of integral domain) which in turn implies $r_1 \cdot a + r_0 = r_0 = 0$. Conclude that $r = 0$ and hence $f = q \cdot g$. By Gauss's lemma, we have $g \in \mathbb Z[x]$. which means $2a, a^2 - b^2n \in \mathbb Z$.
Since $2a \in \mathbb Z$, it must follow that $2b \in \mathbb Z$, for suppose it weren't: We can observe that $(2a)^2 - n(2b)^2 = 4(a^2 - nb^2) \in \mathbb Z$ which means $n(2b)^2 \in \mathbb Z$. If $2b \notin \mathbb Z$, then it would have some prime $p \neq 2$ in the denominator which means $p^2$ would be in the denominator of $(2b)^2$. Multiplying by $n$ cannot cancel $p^2$ as $n$ is squarefree by hypothesis, a contradiction to $n(2b)^2 \in \mathbb Z$.
If $n \equiv 1 \pmod 4$ and $a \equiv b \equiv \frac12 \mod \mathbb Z$, then we're done, so suppose this is not true. We want to show that it must follow that $a, b \in \mathbb Z$. If $2a \in 2\mathbb Z + 1$, then $2b \in 2\mathbb Z + 1$ also, say $2a = 2x + 1$ and $2b = 2y + 1$. Then $$(2a)^2 - n(2b)^2 = (2x + 1)^2 - n(2y + 1)^2 = 4x^2 + 4x + 1 - n(4y^2 + 4y + 1) \in 4\mathbb Z$$ which means $1 - n \in \mathbb Z$ or in other words $n \equiv 1 \pmod 4$, a contradiction. Conclude that $2a, 2b \in 2\mathbb Z$ and hence $a, b \in \mathbb Z$.
$(\Longleftarrow)$: If $a, b \in \mathbb Z$, observe that $\alpha$ is a root of $$f(x) = x^2 - 2ax + (a^2 - b^2n)$$ where $-2a, a^2 - b^2n \in \mathbb Z$, so $\alpha$ is integral over $\mathbb Z$.
If $a \equiv b \equiv \frac12 \mod \mathbb Z$ and $n \equiv 1 \pmod 4$, where $\displaystyle a = \frac{s}{2}$ and $\displaystyle b = \frac{t}{2}$ with $s, t \in 2\mathbb Z + 1$, then we can write $$\alpha = a + b \sqrt n = \frac{s}{2} + \frac{t}{2} \sqrt n = u + v \bigg(\frac{1 + \sqrt n}{2} \bigg)$$ for some $u, v \in \mathbb Z$. Observe that $\alpha$ is a root of $$f(x) = x^2 - (2u + v)x + \bigg(u^2 + uv + \frac14 (1 - n) v^2\bigg)$$ where $-(2u - v), u^2 + uv + \frac14 (1 - n) v^2 \in \mathbb Z$, so $\alpha$ is integral over $\mathbb Z$.
