I have this two-part exercise on a homework paper. The first one should be correct, but I have serious doubts about the second. Usually, when I try to approach the exercises so "manually", I end up to make some mistake, specially when the solution seems elaborated.
Show that the integral closure of $\mathbb Z$ in $\mathbb Q(\sqrt{5})$ is $\mathbb Z[\frac 12(1+\sqrt{5})]$; it is known that this ring is a UFD.
Being a UFD, $\mathbb Z[\frac 12(1+\sqrt{5})]$ is integrally closed in its field of fractions, i.e. $\mathbb Q(\sqrt{5})$. Plus the element $\frac 12(1+\sqrt{5})$ is integral over $\mathbb Z$, because it is a solution of $x^2-x-1\in\mathbb Z[x]$, meaning that the integral closure of $\mathbb Z$ in $\mathbb Q(\sqrt{5})$ is exactly $\mathbb Z[\frac 12(1+\sqrt{5})]$ (the integral elements form a ring).
Show that the integral closure of $\mathbb Z$ in $\mathbb Q(\sqrt{-5})$ is $\mathbb Z[\sqrt{-5}]$; it is known that this ring is not a UFD.
Given an element $x\in\mathbb Q(\sqrt{-5})$, it can be written as $r+s\sqrt{-5}$, with $r,s\in \mathbb Q$. If $x$ is integral over $\mathbb Z$, its minimal polynomial over $\mathbb Q$ must have integer coefficients; in general such minimal polynomial is $X^2-2rX+r^2+5s^2$. The fact that $2r\in \mathbb Z$ means that $r=\frac a2$, for an $a\in\mathbb Z$; let also $s=\frac bc$, for $b,c\in \mathbb Z$ coprime. Now we check that $r^2+5s^2\in \mathbb Z$.
If $2$ doesn't divide $c$, then $\frac{a^2c^2+20b^2}{4c^2}\in \mathbb Z$. Necessarily $(ac)^2$ is divisible by $4$ and $ac$ is divisible by $2$; by assumption, $2$ must divide $a$. In this case $r\in\mathbb Z$, so that $5s^2\in\mathbb Z$. Since $5$ is square-free, $c=1$ and $s\in\mathbb Z$.
If instead $c=2d$, for a $d\in\mathbb Z$, we have that $\frac{a^2d^2+5b^2}{4d^2}\in \mathbb Z$. Necessarily $5b^2$ is divisible by $d^2$; since $b$ and $c$ are coprime, $b$ and $d$ are coprime as well, meaning that $d^2$divides $5$ and $d=1$. Thus $c=2$, and $\frac{a^2+5b^2}{4}\in \mathbb Z$. Observe that if $a^2+5b^2$ is divisible by $4$, also $a^2+b^2$ is; plus we can assume that $2$ doesn't divide either $a$ (we already saw this case) or $b$ (we took $b,c$ coprime).
We are left to prove that $a^2+b^2$ is not divisible by $4$, if $a,b\in\mathbb Z$ aren't divisible by $2$. Write $b$ as $a+n$, for $n\in\mathbb Z$. Then $4$ should divide $2a^2+2na+n^2$, so we can say that $2$ divides $n$. Hence $n=2m$, with $m\in\mathbb Z$, and $4$ should divide $2a^2+4ma+4m^2$, implying that $a^2$ would be divisible by $2$. This can't be possible, for $a$ is assumed to be odd.