I am looking through the PARI/GP reference card.
Example, listing primes over $\mathbb{Z}$ is standard computer homework exercise [1]:
- 100129
- 126691
- 193013
- 284933
- 492113
- 769591
How to write a program to find Gaussian prime numbers $\mathfrak{p} = a + bi \in \mathbb{Z}[i]$ with $10^6 < |a|, |b| < 2 \times 10^6$ ?
Related:
I will compute below the numbers $\mathfrak p=a+ib$ constrained to the following "triangle" restrictions: $$ 10^6< b<a<2\cdot 10^6\ .$$ (From here build conjugates and associates to get also $\pm a\pm ib$ and $\pm b\pm ia$.)
In particular, $\mathfrak p\not\in\Bbb Z$, so $p:=\mathfrak p\bar{\mathfrak p}=a^2+b^2$ is a prime in $\Bbb Z$ which splits in two parts in the Gaussian integers. Here, $p$ is congruent to $1$ modulo four lying in the interval $J$ between $2\cdot 10^{12}$ and $8\cdot 10^{12}$.
One (slow) algorithm would take all these primes $p$ one by one, write them in the form $p=a^2+b^2$ and check the "triangle" condition. There are roughly some
primes in $J$, and half of them split in $\Bbb Z[i]$. A lot of primes for my taste. Below, there is an old fashioned pari/gp code implementing this slow algorithm. (It avoids the prime $1+i$, just in case somebody wants to relax $b<a$ to $b\le a$...)
The "real job" is done by the pari/gp factorization of Gaussian integers, a prime
pin $\Bbb Z$ was slightly changed toI*pto implicitly tell pari/gp to factor over $\Bbb Z[i]$.Then
f(100)delivers some $579$ such (normed) primes, and there is a quick end. The last ones are:Seen from this perspective, this algorithm seems to be "better" than the brute force algorithm considering all $(a,b)$ with $100<b<a<200$, and testing for the primality of $a+ib$. At the cost of having a good primes generator for $\Bbb Z$.
I have also started...
and the primes are slowly printed one by one, as they are fished and tested for relevant...