# Second longest prime diagonal in the Ulam spiral?

Given the Ulam spiral with center $C = 41$ and the numbers in a clockwise direction, we have,

$$\begin{array}{cccccc} \color{red}{61}&62&63&64&\to\\ 60&\color{red}{47}&48&49&50\\ 59&46&\color{red}{41}&42&51\\ 58&45&44&\color{red}{43}&52\\ 57&56&55&54&\color{red}{53}&\downarrow\\ \leftarrow \end{array}$$

The main diagonal is defined by Euler's polynomial $F(n) = n^2+n+41$, and yields distinct primes for 40 consecutive $n = 0\,\text{to}\,39$.

If we let $C = 3527$, we get,

$$\begin{array}{cccccccc} \color{blue}{3569}&3570&3571&3572&3573&3574&\to\\ 3568&\color{red}{3547}&3548&3549&3550&3551&3552\\ 3567&3546&\color{red}{3533}&3534&3535&3536&3553\\ 3566&3545&3532&\color{red}{3527}&3528&3537&3554\\ 3565&3544&3531&3530&\color{red}{3529}&3538&3555\\ 3564&3543&3542&3541&3540&\color{red}{3539}&3556\\ 3563&3562&3561&3560&3559&3558&\color{red}{3557}&\downarrow\\ \leftarrow \end{array}$$

The polynomial is $G(n) = 4n^2-2n+3527$ and is prime for 23 consecutive $n = -2\,\text{to}\,20$. (The blue number, $G(-3)=3569$ is not prime.)

1. Letting $C$ be the "origin", then $G(n)$ is only in the 4th Cartesian quadrant for $n>0$. (Unlike Euler's which spans the 2nd and 4th quadrants.)

2. The square-free discriminant is $d = -14107$ and has class number $h(d) = 11$. This is the 3rd largest (in absolute value) with that $h(d)$.

3. This beats $F(n)=n^2+n+17$, $d = -67$, $h(d) = 1$ which yields distinct primes only for 16 consecutive n.

Question:

1. For $F(n) = n^2+n+p$, the record is held by Euler's polynomial. For the form $F(n) = 4n^2\pm 2n+p$, is there a better one?

P.S. Other polynomials such as $F(n) = 6n^2+6n+31$ are prime for $n=0\,\text{to}\,28$, but are not diagonals in the Ulam spiral.

-
The primes are arise from consecutive values of the polynomial, great. What about prime rich polynomials? I recall finding such values, don't have any idea if they set records. In any case these diagonals are evident upon inspection. That the class number h(d) = 11 is interesting! –  Alan Nov 9 '13 at 0:43
According to the prime constellation conjecture, there should be arbitrarily large diagonal sequences. This contradicts your "For $F(n)=n^2+n+p$ the record is for $p=41$". Euler's polynomial is special because $F(n)$ is prime for $0 \le n \le \frac{1+\sqrt{(p-1)/3}}2$ if and only if $h(1-4p)=1$ if and only if $F(n)$ is prime for $0 \le n \le p-2$. Sadly, $p=41$ is the largest such prime, so it gives the most spectacular sequence (in terms of its length compared to $p$). Every other sequence fails in $O(\sqrt p)$. –  mercio Nov 10 '13 at 9:24
I found an old piece of code that runs grids of values and reports back prime rich polynomials. So...$2753 - 810n - 36n^2$ has 132 primes between n = -100 and n = 100. and $3572 - 2n + 4n^2$ has 122 primes in the the same interval. –  Alan Nov 10 '13 at 22:41
@mercio: The prime constellation does not seem to discuss primes in a quadratic progression. In fact, the k-Tuple Conjecture explicitly states it implies arbitrarily long arithmetic progressions of primes, but is silent on quadratic ones. –  Tito Piezas III Nov 11 '13 at 2:08
@mercio: This MO post on prime constellation conjectures has an answer from Green and Tao's "Linear Equations in Primes". –  Tito Piezas III Nov 11 '13 at 2:16