Prime-generating polynomial · Official record

Polynomial (L = 31)

A Prime-Generating Monic Cubic Polynomial

Documented by Paolo Borghi — Verified computationally (2025)

The polynomial

f(n) = n³ + 54n² − 2329n + 20507

The Polynomial is a cubic integer polynomial that produces a run of 31 consecutive prime values when evaluated at consecutive integers starting at n = 0. As usual in this context, primality is tested on the absolute value |f(n)|.

Category: monic cubic prime-generating polynomial

The polynomial

f(n) = n³ + 54n² − 2329n + 20507

is a monic cubic polynomial, since the leading coefficient (the coefficient of ) is equal to 1. This places it within the class of monic cubic prime-generating polynomials, a mathematically significant and more restrictive family compared to non-monic cubic polynomials.

In this stricter category, achieving a long consecutive prime run is notably difficult. The Borghi Polynomial attains a run length of:

L = 31

making it one of the longest documented prime-generating runs for a monic cubic polynomial.

Formal statement of the record

Let f(n) = n³ + 54n² − 2329n + 20507. Define the run length L as the largest integer such that |f(n)| is prime for all integers n with 0 ≤ n ≤ L − 1.

For the Borghi Polynomial we have:

L = 31

i.e. |f(n)| is prime for all n = 0, 1, 2, …, 30, and the first composite value occurs at n = 31.

First composite value:
n = 31 -> f(31) = 29993 = 89 × 337

The discovery that produced this report used the following domain:
a ∈ [−2500, +2500], b ∈ [−2500, +2500], c ∈ [2, 80000]

Prime values for 0 ≤ n ≤ 30

The table below lists the 31 consecutive prime values produced by f(n) = n³ + 54n² − 2329n + 20507 for integers n = 0, 1, …, 30.

n f(n) is prime
020507
118233
216073
314033
412119
510337
68693
77193
85843
94649
103617
112753
122063
131553
141229
151097
161163
171433
181913
192609
203527
214673
226053
237673
249539
2511657
2614033
2716673
2819583
2922769
3026237

Computational verification (sketch)

The record was established by exhaustive evaluation of f(n) for consecutive integers and deterministic primality tests up to the first composite value. No probabilistic methods (e.g. Miller–Rabin with bases) were needed for this range; simple trial division up to sqrt(x) is sufficient.

The computation is lightweight for verifying a single polynomial and can be reproduced on standard hardware in a fraction of a second.

Reproducibility: minimal Python snippet

Any reader can verify the run length with the following code:

"""
Deterministic primality test for the monic cubic record:

    f(n) = n^3 + 54 n^2 - 2329 n + 20507
"""

A = 54
B = -2329
C = 20507

def is_prime(n: int) -> bool:
    if n < 2:
        return False
    if n % 2 == 0:
        return n == 2
    d = 3
    while d * d <= n:
        if n % d == 0:
            return False
        d += 2
    return True

def f(n: int) -> int:
    return n**3 + A*n**2 + B*n + C

def main():
    primes = []
    n = 0
    while True:
        v = f(n)
        if v < 2 or not is_prime(abs(v)):
            break
        primes.append((n, v))
        n += 1

    L = len(primes)
    print("Record triple:")
    print(f"  (a, b, c) = ({A}, {B}, {C})")
    print("\nLength of the consecutive prime run (L):", L)
    print(f"First composite at n = {L}: f(n) = {f(L)}")

if __name__ == "__main__":
    main()

Running this program will output Run length L = 31, confirming the claimed record.

Record summary

  • Name Borghi Polynomial
  • Degree 3 (cubic)
  • Form f(n) = n³ + 54n² − 2329n + 20507
  • Coefficients a = 54, b = −2329, c = 20507
  • Run length L = 31
  • Domain consecutive n ≥ 0
  • Primality tested on |f(n)|

Official reference

Zenodo record
P. Borghi, "A Prime-Generating Monic Cubic Polynomial with Run Length L = 31", Zenodo, 2025.
Record: DOI

How to cite

Suggested citation (APA-style):

Borghi, P. (2025). A Prime-Generating Monic Cubic Polynomial 
with Run Length L = 31. Zenodo. (DOI pending)

Author

Paolo Borghi
Independent researcher in number theory and prime-generating polynomials.
paolo.borghi@gmail.com