Suppose $K=\mathbb{Q}(\sqrt d)$ be the quadratic extension of $\mathbb{Q}$ and let $O_K$ be the ring of integers (free $\mathbb{Z}$-module), then
$(i)$ if $d \equiv 2,3 \pmod 4$, the integral basis of $O_K$ is $\{1, \sqrt d\}$,
$(ii)$ if $d \equiv 1 \pmod 4$, the integral basis of $O_k$ is $\{1, \frac{1+\sqrt d}{2} \}$.
Answer:
I am having problem of choosing these bases. In the proof it is given that:
$(i)$ if $d \equiv 2,3 \pmod 4$, then $a^2 \equiv b^2d \pmod 4$, $a,b \in \mathbb{Z}$, which indicate either $a$ and $b$ must be even and hence $\{1, \sqrt d\}$ is an integral basis.
My question is how the above logic shows $\{1, \sqrt d \}$ is a basis ?
Help me