Let $d \in \mathbb Z$ and let $\sqrt{d} \in \mathbb C$ be a square root of $d$. Consider the subring of $\mathbb C$, $$\mathbb Z[{d}]=\{a+b\sqrt{d}: a,b \in \mathbb Z \}$$ and we define the norm of an element in $\mathbb Z[\sqrt{d}]$ by $N(a+b\sqrt{d})=a^2-db^2$.
Prove the following:
1) $z \in \mathbb Z[\sqrt{d}]$ is a unit if and only if $N(z)=\pm1$.
2) The ring $\mathbb Z[\sqrt{d}]$ is prefactorial, i.e., every non zero element which is not a unit can be written as product of irreducible elements.
I'll write what I could do:
1) Suppose $N(z)=\pm 1$, where $z=a+b\sqrt{d}$. Then $(a+b\sqrt{d})\dfrac{a-b\sqrt{d}}{a^2-b^2d}=1$, so the candidate for $z^{-1}$ is $\dfrac{a-b\sqrt{d}}{a^2-b^2d}$. From here it is clear that if $N(z)=\pm 1 \implies z^{-1} \in Z[\sqrt{d}]$. I couldn't prove the other implication.
I don't know what to do in 2), I would appreciate suggestions.
The proof for 2) is very similar to the analogous theorem in $\mathbb{Z}$. Consider the set $S= \{x \mid x\text{ cannot be written as a product of irreducibles}\}$. Suppose the set is non-empty and notice that $\{|N(x)| \mid x\in S\}$ is a subset of $\mathbb{N}$ so you can use the Well-Ordering princple to choose a least element. Note that the least element that you pick can factor into two numbers that are strictly less than it (otherwise it would not be in the set).
Can you find the contradiction from there?