TITLE: If $\mathcal{O}_{\Bbb{Q}(\sqrt{d})}$ has class number $2$ or higher, does that mean $\sqrt{d}$ is irreducible but not prime?
QUESTION [5 upvotes]: Actually, I do know of exceptions to this, that's when $d$ is prime in $\Bbb{Z}$, e.g., $\Bbb{Z}[\sqrt{-79}]$ has class number $5$ and $\mathcal{O}_{\Bbb{Q}(\sqrt{79})}$ has class number $3$, but obviously $\sqrt{-79}$ and $\sqrt{79}$ have prime norms and are thus primes in their respective domains.
But if $d$ is a negative composite number, say $d = -pq$ (where $p$ and $q$ are positive primes) then obviously $p$ and $q$ are both irreducible but neither is prime. And what if $d = pq$ or some other positive composite number?
I've worked through a few specific examples. Like in $\Bbb{Z}[\sqrt{-10}]$, norms $2$ and $5$ are impossible, so $10$ has two distinct factorizations. And in $\Bbb{Z}[\sqrt{10}]$, it is easy to see that $2$ is irreducible, though it takes a little more work to show that $5$ is irreducible as well.
Obviously this is too laborious, especially if the smallest counterexample is some number with a thousand prime factors.
Also, I'm not sure why last night I was looking up "real quadratic fields of
generalized ERD-type" (a paper by Xianke and Fuhua only left me more confused). Does anyone even know what ERD-type is?
But my main question is this: can $d$ be composite in $\Bbb{Z}$, $\mathcal{O}_{\Bbb{Q}(\sqrt{d})}$ has class number greater than $1$, yet $\sqrt{d}$ is composite in $\mathcal{O}_{\Bbb{Q}(\sqrt{d})}$?

REPLY [3 votes]: I think I have found a necessary condition, I'm fairly confident that it is necessary. That it is sufficient, I am quite less confident, because it could be the case that I have stopped checking one or two short of the counterexample.
Given $d$ being the product of two or more distinct positive primes $p_i$, if for any $p_i$ we find that neither $p_i$ nor $-p_i$ is a quadratic residue modulo $p_j$ for any $j \neq i$, then $d$ as number must have two distinct factorizations in $\mathcal{O}_{\textbf{Q}(\sqrt{d})}$, and the ideal $\langle d \rangle$ has a unique factorization into ideals but only some, if not none, of those ideals are principal.
But if either $p_i$ or $-p_i$ is a quadratic residue modulo $p_j$ for each $j \neq i$, then $d$ probably only has one distinct factorizations in $\mathcal{O}_{\textbf{Q}(\sqrt{d})}$, and perhaps, but not always, that is a unique factorization domain.
For example, in $\textbf{Z}[\sqrt{6}]$, we find that $2$ is not a quadratic residue modulo $3$, but $4 \equiv -2$ is, and so $$(-1)(2 - \sqrt{6})(2 + \sqrt{6})(3 - \sqrt{6})(3 + \sqrt{6}) = 6,$$ but in $\textbf{Z}[\sqrt{10}]$, neither $2$ nor $3$ are quadratic residues modulo $5$. Psychologically, this is not surprising because we know the former is a norm-Euclidean while the latter is not even a unique factorization domain.
More interesting is $\textbf{Z}[\sqrt{34}]$, where we find that $6^2 \equiv 2 \pmod {17}$, and therefore $$(-1)(6 - \sqrt{34})(6 + \sqrt{34})(17 - 3 \sqrt{34})(17 + 3 \sqrt{34}) = 34,$$ and so it becomes obvious that both $\langle 6 + \sqrt{34} \rangle$ and $\langle 17 + 3 \sqrt{34} \rangle$ are principal ideals.
Likewise with $\textbf{Z}[\sqrt{55}]$ we find that $4^2 \equiv 5 \pmod {11}$. I have checked up to $\textbf{Z}[\sqrt{195}]$ but have doublechecked only some of those calculations.