Let's generate a few prime numbers.
Last time I tried to show off the $n^2-n+41$ formula for prime numbers it did not go well. Everyone said it was old hat, known since Euler. After this debacle I then decided to try a couple formulas of my own:
$n^2+14$
$n^2+30$
Of course, neither one is going to give $n^2-n+41$ a run for its money; formula (1) is bound to fail for multiples of $2$ or $7$ and (2) will have problems with multiples of $2,3,5$. But what if I use only values of $n$ that are prime to the constant term?
Formula (1) gives:
$1^2+14=15$
$3^2+14=\color{blue}{23}$
$5^2+14=39$
$9^2+14=95$
Well, that is largely a dud, maybe formula (2) will work a little better with appropriate values of $n$:
$1^2+30=\color{blue}{31}$
$7^2+30=\color{blue}{79}$
$11^2+30=\color{blue}{151}$
$13^2+30=\color{blue}{199}$
$17^2+30=319(=11×29)$
Although only four primes are produced before we run into composite numbers, this result is clearly better than the one with $n^2+14$. The latter requires going all the way up to $n=33$, using fifteen values of $n$ that are prime to $14$, to give four primes. Surely my audience will appreciate the fact that the $n^2+30$ form is associated with a quadratic domain with class number 4, and so I did not resort to a UFD.
Or did I?
Pulling two and two apart
Why does $n^2+30$ generate prime numbers more efficiently for small $n$ than $n^2+14$?
Both $\mathbb Z[\sqrt{-14}]$ and $\mathbb Z[\sqrt{-30}]$ have class number 4, but there the similarity ends: the former has class group $\mathbb Z/4\mathbb Z$, whereas the latter has instead $\mathbb Z/2\mathbb Z×\mathbb Z/2\mathbb Z$.
As I explain here, when a domain has a class group consisting only of two-cycles -- like the Klein four-group for $\mathbb Z[\sqrt{-30}]$ but unlike the cyclic four-group for both $\mathbb Z[\sqrt{-14}]$ and $\mathbb Z[\sqrt{-17}]$ -- it can be augmented with numbers having the form
$k\sqrt{a}+m\sqrt{b}$
for properly constructed values of $a$ and $b$ and $k,m$ either both integers or in some cases both half-integers. With $\mathbb Z[\sqrt{-30}]$ we use three augmentations, all with $k$ and $m$ both integers:
$k\sqrt{15}+m\sqrt{-2}$
$k\sqrt{10}+m\sqrt{-3}$
$k\sqrt6+m\sqrt{-5}$
When these are overlaid on the $\mathbb Z[\sqrt{-30}]$ domain, all elements of the latter factor uniquely. For instance, $34$ is both $2×17$ and $(2+\sqrt{-30})(2+\sqrt{-30})$, but with the augmented domain as defined above these are both resolved into the unique factorization $(-1)(\sqrt{-2})^2(\sqrt{15}+\sqrt{-2})(\sqrt{15}-\sqrt{-2})$.
Because of this modified version of unique factorization in a Klein-four class group domain, $n^2+30$ is forced to have factors with one of the forms
$15k^2+2m^2, 10k^2+3m^2, 6k^2+5m^2.$
When we set $n$ prime to $30$,the most obvious factors having these quadratic forms are excluded and, resembling $n^2-n+41$ after all, a rather large value of the function is needed to find other factors (for $319$, the factors are $6(1^2)+5(1^2)$ and $6(2^2)+5(1^2)$).
My audience should be impressed by this mathematical ingenuity!