Primes in $\mathbb{Z}[\sqrt{2}]$?

That ring is a unique factorization domain. The primes are $\sqrt{2}$, the rational primes congruent to $\pm 3 \pmod{8}$ and the two factors of each of the rational primes congruent to $\pm 1 \pmod{8}$. Those rational primes factor precisely because they have $2$ as a quadratic residue and therefore the ones that can be written as a difference $$ p = x^2 - 2y^2 = (x + y\sqrt{2}) (x - y\sqrt{2}) . $$ So, for example, the prime factorization of $7$ is $$ 7 = (3 + \sqrt{2}) (3 - \sqrt{2}) . $$

This idea generalizes straightforwardly when the ring happens to enjoy unique factorization (which is rare). It gets a lot more complicated in general.

You can read all about the uncomplicated cases in Elementary Number Theory: An Algebraic Approach.


The very first thing to note is that 2 is not prime in this ring since $(\sqrt 2)^2 = 2$. Neither is $-2$, since $(-1)(\sqrt 2)^2 = -2$. Likewise 2 is not prime in $\mathbb Z[\sqrt{-2}]$, since $(-1)(\sqrt{-2})^2 = -2$.In both rings, 2 is said to "ramify," which is the case since it's a multiple of the radicand; trivial multiples are okay here. (By the way, 2 is not prime in $\mathbb Z[i]$ either, since $(1 - i)(1 + i) = 2$, and it's also ramified in that domain, but it won't be until you understand ideals that that will make any sense).

Next we look at the odd primes. Suppose $p$ is a positive odd prime. Then, using the Legendre symbol, if $$\left(\frac{2}{p}\right) = -1,$$ the equation $x^2 \equiv 2 \pmod p$ has no solutions in integers, and then neither does $x^2 - 2y^2 = \pm p$.

But if instead $$\left(\frac{2}{p}\right) = 1,$$ the equation $x^2 \equiv 2 \pmod p$ does have solutions in integers, and hopefully so does $x^2 - 2y^2 = \pm p$ (actually, it always does, but it might not if instead we were looking for something like $x^2 - 10y^2 = \pm p$ with the corresponding Legendre symbol of 1).

Since $$\left(\frac{2}{p}\right) = 2^{\frac{p - 1}{2}} \pmod p,$$ we can further determine $$\left(\frac{2}{p}\right) = (-1)^{\frac{p^2 - 1}{8}}.$$ So if $p \equiv 1, 7, 9, 15 \pmod{16}$, it follows that $p^2 - 1$ is a multiple of 16 and so $$\frac{p^2 - 1}{8}$$ is even and therefore $$\left(\frac{2}{p}\right) = (-1)^{\frac{p^2 - 1}{8}} = 1.$$

Contrast that to $p \equiv 3, 5, 11, 13 \pmod{16}$. Then $p^2 \equiv 9 \pmod{16}$ and so $$\frac{p^2 - 1}{8}$$ is odd and therefore $$\left(\frac{2}{p}\right) = (-1)^{\frac{p^2 - 1}{8}} = -1.$$

If the Legendre symbol tells us that $x^2 \equiv 2 \pmod p$ has solutions, then the least positive $x$ will give us a number $x + \sqrt 2$ such that $(x - \sqrt 2)(x + \sqrt 2) = mp$. Sometimes $m = 1$, in which case we're done, as in the example of 7 Ethan Bolker gave in his answer.

In this domain we won't have to worry about $m$ being negative, but it could be greater than 1. For example, $$\left(\frac{2}{17}\right) = 1$$ and the least solution to $x^2 \equiv 2 \pmod{17}$ is $x = 6$, but $(6 - \sqrt 2)(6 + \sqrt 2) = 34$, not 17. Not to worry, though: $$\frac{6 + \sqrt 2}{\sqrt 2} = 1 + 3 \sqrt 2,$$ and $(-1)(1 - 3 \sqrt 2)(1 + 3 \sqrt 2) = 17.$

Primes like 7 and 17 are said to "split" in this domain (they are composite and "split" into two prime factors), while primes like 3 and 13 are said to remain "inert."

One nice thing about $\mathbb Z[\sqrt 2]$ is that the fundamental unit, $1 + \sqrt 2$, has a norm of $-1$. But if the fundamental unit instead has norm 1, we have to watch out for the possibility that the Legendre symbol tells us $p$ splits yet $(x - \sqrt d)(x + \sqrt d) = p$ is insoluble. If such a domain is a unique factorization domain, then we can still count on $(x - \sqrt d)(x + \sqrt d) = -p$ being soluble.

Such is the case in $\mathbb Z[\sqrt 3]$, in which domain the fundamental unit is $2 + \sqrt 3$, which has norm 1, not $-1$. We see that $$\left(\frac{3}{11}\right) = 3^{\frac{11 - 1}{5}} = 1 \pmod{11}.$$ Then we find the least positive $x$ to solve $x^2 \equiv 3 \pmod{11}$ is $x = 5$, which gives us $(5 - \sqrt 3)(5 + \sqrt 3) = 22$.

Since 22 is not divisible by 3, we can't divide $5 \pm \sqrt 3$ by $\sqrt 3$, so now we have to divide it by a factor of 2. So as to not make this longer than it already is, please accept it on my say so that we need to divide by $1 + \sqrt 3$. Thus we get $$\frac{5 + \sqrt 3}{1 + \sqrt 3} = -1 + 2 \sqrt 3$$ and $(-1 - 2 \sqrt 3)(-1 + 2 \sqrt 3) = -11$. The factorization of 11 is therefore $(-1)(1 - 2 \sqrt 3)(1 + 2 \sqrt 3)$.

In this domain 3 is a ramifying prime. As it turns out, 2 is also ramifying, but again, you'll need to understand ideals to wrap your head around that.

Also, you will need the Kronecker symbol in addition to the Legendre symbol to help you factorize 2. The Legendre symbol will be a trusty tool for the odd primes.

This is a very deep and interesting topic, and I could go on and on about it. I hope that this is sufficient to guide the next step of your study.