Statement

For the K=Q(−d)K=\mathbb Q(\sqrt{-d}), where d>0d>0 is square-free, the is

OK={Z[(1+−d)/2],d≡3(mod4),Z[−d],d≡1,2(mod4).\mathcal O_K=\begin{cases} \mathbb Z[(1+\sqrt{-d})/2],&d\equiv3\pmod4,\\ \mathbb Z[\sqrt{-d}],&d\equiv1,2\pmod4. \end{cases}

Square-freeness excludes d≡0(mod4)d\equiv0\pmod4.

Why the half-integer occurs

An element of a quadratic field is integral exactly when its trace and norm are integers. Write it as (a+b−d)/2(a+b\sqrt{-d})/2. These conditions force a,b∈Za,b\in\mathbb Z and a2+db2≡0(mod4)a^2+db^2\equiv0\pmod4. Either both are even, or both are odd and d≡3(mod4)d\equiv3\pmod4. This gives precisely the displayed rings.

Examples

For d=1d=1 this is the Gaussian integer ring. For d=3d=3 it is the Eisenstein integer ring, which can equally be written Z[(−1+−3)/2]\mathbb Z[(-1+\sqrt{-3})/2].

References
  1. J. S. Milne, Algebraic Number Theory, v3.08. Author’s text, Introduction and §2, Remark 2.12.