Let $n$ be a square-free integer such that $n\equiv 2,$ or $3\bmod 4$. If $p\in\mathbb{Z}$ be a prime such that $n$ is not a square modulo $p$, then $(p)$ is a prime ideal in $\mathbb{Z}[\sqrt{n}]$. On the other hand, if $p$ is odd and $n$ is a square mod $p$, then $(p)=\mathfrak{p}_1\mathfrak{p}_2$, and if $p$ does not divide $n$, then $\mathfrak{p}_1$ and $\mathfrak{p}_2$ are distinct.
First, I show that the integral closure of $\mathbb{Z}$ in $\mathbb{Q}[\sqrt{n}]$ is $\mathbb{Z}[\sqrt{n}]$.
Write $R$ for the integral closure.
$\mathbb{Z}[\sqrt{n}]\subseteq R$: If $z=a+b\sqrt{n}$ for $a,b\in\mathbb{Z}$, then $(z-a)^2-b^2n=0$, so $z$ satisfies $m_z(x)=(x-a)^2-b^2n$ which is monic.
$R\subseteq\mathbb{Z}[\sqrt{n}]$: If $z=r+q\sqrt{n}$ for $r,q\in\mathbb{Q}$, then $m_z(x)=(x-r)^2-q^2n$ is the minimal polynomial for $z$ over $\mathbb{Q}$ for the same reasons as above. $z$ is integral if and only if its polynomial lies in $\mathbb{Z}[x]$, so $m_z$ has coefficients in $\mathbb{Z}$. The coefficients are $-2r$ and $r^2-q^2n$. (don't know where to go from here)
As in the hint, we have that both of these must be integers, so $R^2\equiv Q^2d\pmod 4$, so $R,Q$ are even, so $r,q\in\mathbb{Z}$.
Now, how do I determine the primality (or factorization) of $(p)$?
Since $r+q\sqrt n$ is integral, the coefficients $-2r$ and $r^2 - q^2 n$ are integers. It follows that $r, q \in \frac 12 \mathbb Z$. Write $r = R/2$ and $q = Q/2$. Then $r^2 - q^2 n = (R^2 - Q^2 n)/4 \in \mathbb Z$, so that $$ R^2 \equiv Q^2 n \mod 4 . $$ For $n \equiv 2,3 \bmod 4$, check that this implies that $R$ (and hence $Q$ as well) is even, so that $r$ and $q$ are integers.