1. Home
  2. Explore
  3. Mathematics
  4. Prime Generating Recurrence

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Prime Generating Recurrence

The Prime-Generating Recurrence: Sequence R(n)

Definition and Basic Behavior

The recurrence defines a sequence R(n)R(n)R(n) where:

  • Initial term: R(1)=7R(1) = 7R(1)=7 (chosen arbitrarily; other starting values are explored later)

  • Recurrence: R(n)=R(n−1)+gcd⁡(n,R(n−1))R(n) = R(n-1) + \gcd(n, R(n-1))R(n)=R(n−1)+gcd(n,R(n−1)) for n>1n > 1n>1

This is similar to the Fibonacci recurrence but only depends on one previous term (the gcd replaces the second previous term).

First few terms

Starting with R(1)=7R(1)=7R(1)=7:

  • R(2)=7+gcd⁡(2,7)=7+1=8R(2) = 7 + \gcd(2,7) = 7+1 = 8R(2)=7+gcd(2,7)=7+1=8

  • R(3)=8+gcd⁡(3,8)=8+1=9R(3) = 8 + \gcd(3,8) = 8+1 = 9R(3)=8+gcd(3,8)=8+1=9

  • R(4)=9+gcd⁡(4,9)=9+1=10R(4) = 9 + \gcd(4,9) = 9+1 = 10R(4)=9+gcd(4,9)=9+1=10

  • R(5)=10+gcd⁡(5,10)=10+5=15R(5) = 10 + \gcd(5,10) = 10+5 = 15R(5)=10+gcd(5,10)=10+5=15 ← first jump

  • R(6)=15+gcd⁡(6,15)=15+3=18R(6) = 15 + \gcd(6,15) = 15+3 = 18R(6)=15+gcd(6,15)=15+3=18

  • Then returns to increments of 1 for several terms.

The sequence displays long stretches of incrementing by 1 (boring behavior) interrupted by sudden jumps. The gcds collected separately reveal the pattern:

  • Gcd sequence: 1,1,1,5,3,1,1,1,1,... (the 1s are "boring", the non‑1 gcds are the jumps)

Observed Patterns in the Gcds

All non‑1 gcds are prime

When the 1s are removed, the remaining gcds form an increasing sequence of primes: 5, 3, 11, 3, 23, 3, 47, 3, 5, 3, 101, ...

  • This was discovered experimentally in 2003 by Stephen Wolfram's group.

  • Surprising because gcds are inherently connected to divisibility, but the fact that they are always prime is not obvious.

Doubling relation between primes

Some primes appear to double (plus or minus 1):
2×5+1=112 \times 5 + 1 = 112×5+1=11, 2×11+1=232 \times 11 + 1 = 232×11+1=23, 2×23+1=472 \times 23 + 1 = 472×23+1=47
But this pattern does not continue: 2×47+1=952 \times 47+1=952×47+1=95, which is not prime and does not appear.

Other pairs: 101 and 3 do not follow this; instead, 101 is close to 2×51−12 \times 51 - 12×51−1.
This gives a clue: the relation involves the index of the previous prime, not the prime itself.

Cluster structure and logarithmic scaling

Plotting the indices where non‑1 gcds appear (i.e., the nnn values) reveals clusters. A logarithmic scale (like the Richter scale for earthquakes) makes the pattern clear: the clusters are evenly spaced vertically on a log plot.

  • Logarithmic scale: The distance between 10 and 100 equals the distance between 100 and 1000. This transforms multiplicative growth into linear spacing.

  • The vertical spacing between cluster averages corresponds to multiplication by a constant ≈ 2.

  • Thus, the runs of 1s between clusters roughly double in length.

The real pattern: indices, not primes

The first prime in each cluster comes from the index of the previous prime, not from the previous prime itself:

  • From index 6 (prime 3) → first prime of next cluster = 2×6−1=112 \times 6 - 1 = 112×6−1=11

  • From index 12 → 2×12−1=232 \times 12 - 1 = 232×12−1=23

  • From index 24 → 2×24−1=472 \times 24 - 1 = 472×24−1=47
    But for the cluster starting at 101, using index 51 (where prime 3 appeared) gives 2×51−1=1012 \times 51 - 1 = 1012×51−1=101 (works).
    Within a cluster (e.g., after 101), the formula 2n−12n-12n−1 does not always give a prime directly; instead it gives a composite, and the actual prime is the smallest prime divisor of 2n−12n-12n−1.

The Conjecture (Now a Theorem)

For any index nnn where gcd⁡(n,R(n−1))≠1\gcd(n, R(n-1)) \neq 1gcd(n,R(n−1))=1:

  1. Next nontrivial gcd: Let ppp be the smallest prime divisor of 2n−12n - 12n−1. Then the next gcd that is not 1 is ppp.

  2. Where it appears: That next gcd occurs at index n+in + in+i, where i=(p−1)/2i = (p-1)/2i=(p−1)/2.

  3. Iterative structure: After reaching index n+in+in+i, the value R(n+i)=3×(n+i)R(n+i) = 3 \times (n+i)R(n+i)=3×(n+i) (a "nice state").

Example for the cluster starting at 467

  • At n=467n=467n=467, 2n−1=933=3×3112n-1=933=3 \times 3112n−1=933=3×311, so p=3p=3p=3, i=1i=1i=1. Next nontrivial gcd at n=468n=468n=468 gives 3.

  • At n=468n=468n=468, 2n−1=935=5×1872n-1=935=5 \times 1872n−1=935=5×187, so p=5p=5p=5, i=2i=2i=2. Next at n=470n=470n=470.

  • At n=470n=470n=470, 2n−1=939=3×3132n-1=939=3 \times 3132n−1=939=3×313, so p=3p=3p=3, i=1i=1i=1. Next at n=471n=471n=471.

  • At n=471n=471n=471, 2n−1=9412n-1=9412n−1=941 (prime), so p=941p=941p=941, i=470i=470i=470. Next at n=941n=941n=941, starting a new cluster.

This process reproduces the cluster exactly without computing the recurrence step by step.

Proof Sketch and the Role of R(n)=3nR(n) = 3nR(n)=3n

The key insight: whenever R(n)=3nR(n) = 3nR(n)=3n, the recurrence behaves nicely.

  • Starting from such a "nice state" at index nnn, applying the recurrence for i=(p−1)/2i = (p-1)/2i=(p−1)/2 steps (where ppp is the smallest prime divisor of 2n−12n-12n−1) leads to a new index m=n+im = n + im=n+i where again R(m)=3mR(m) = 3mR(m)=3m.

  • This property allows the recurrence to be advanced in large jumps, returning to the same form at each step.

  • Combined with the two conjectures (smallest prime divisor and (p−1)/2(p-1)/2(p−1)/2 delay), a rigorous proof shows that all non-1 gcds are prime.

The theorem explains:

  • Why primes are generated: Because R(n)=3nR(n) = 3nR(n)=3n propagates under the recurrence, and the only jumps occur when 2n−12n-12n−1 has a small prime factor (including itself when prime).

  • Why clusters form: When 2n−12n-12n−1 is composite, its smallest prime divisor ppp is small, so i=(p−1)/2i = (p-1)/2i=(p−1)/2 is small, producing a short run of 1s. When 2n−12n-12n−1 is prime, p=2n−1p = 2n-1p=2n−1, so i=n−1i = n-1i=n−1, a long run that starts a new cluster.

Implications and Limitations

Primality testing vs. prime generation

Using the recurrence to find large primes is impractical. To see a 10‑digit prime, the recurrence would need roughly 5×1085 \times 10^85×108 steps (since i≈n−1i \approx n-1i≈n−1). The shortcut requires knowing the smallest prime divisor of 2n−12n-12n−1, which is essentially the same difficulty as primality testing.

Which primes appear?

  • The prime 2 never appears because 2n−12n-12n−1 is odd, so its smallest prime divisor is never 2.

  • After 10,000 applications of the shortcut, the smallest odd prime not yet seen is 587 (only the 107th prime). This suggests many primes may appear, but it is not known if all odd primes eventually appear.

  • In 2011, Chamizo, Raboso, and Ruiz‑Cabello proved that infinitely many distinct primes appear.

Why a 3 is sandwiched between each doubling pair

Within every cluster, the second prime is always 3. This follows from the theorem: the smallest prime divisor of 2n−12n-12n−1 after the first prime is often 3. The pattern can be proved using the recurrence properties.

Variations with Different Initial Terms

Starting with 1, 2, or 3

  • Initial term 1: R(1)=1R(1)=1R(1)=1, then gcd⁡(n,n−1)=1\gcd(n, n-1)=1gcd(n,n−1)=1 for all nnn, so the sequence is 1,2,3,4,…1,2,3,4,\dots1,2,3,4,… (all gcds are 1, no primes).

  • Initial term 2 or 3: Similar boring behavior; no nontrivial gcds appear.

Starting with 4

  • R(1)=4R(1)=4R(1)=4, R(2)=6R(2)=6R(2)=6, R(3)=9R(3)=9R(3)=9, and from n=3n=3n=3 onward the sequence matches the one starting with 7 (since R(3)=9R(3)=9R(3)=9 in both cases). So from that point, the prime-generating property holds.

Starting with 532

  • The sequence initially produces a non‑prime gcd (e.g., 6). It does not immediately satisfy R(n)=3nR(n)=3nR(n)=3n. However, eventually (at n=279n=279n=279) it reaches R(279)=3×279R(279)=3 \times 279R(279)=3×279, and from then on all nontrivial gcds are prime.

  • Open question: For any initial term ≥4\geq 4≥4, does the sequence eventually reach a state R(n)=3nR(n)=3nR(n)=3n? It is conjectured yes, but not proven.

Variation with LCM: Sequence C(n)C(n)C(n)

Benoit Cloitre replaced gcd with lcm (least common multiple). Define C(n)C(n)C(n) with C(1)=1C(1)=1C(1)=1 and

C(n)=C(n−1)+lcm⁡(n,C(n−1)).C(n) = C(n-1) + \operatorname{lcm}(n, C(n-1)).C(n)=C(n−1)+lcm(n,C(n−1)).
  • The lcm is never 1 (since it is divisible by nnn and C(n−1)C(n-1)C(n−1)).

  • The terms C(n)C(n)C(n) grow rapidly and are not primes.

  • Because C(n−1)C(n-1)C(n−1) divides the lcm, C(n)C(n)C(n) is divisible by C(n−1)C(n-1)C(n−1). So the ratio C(n)/C(n−1)C(n)/C(n-1)C(n)/C(n−1) is an integer.

  • Subtract 1 from this ratio to get lcm⁡(n,C(n−1))C(n−1)\frac{\operatorname{lcm}(n, C(n-1))}{C(n-1)}C(n−1)lcm(n,C(n−1))​.

  • Astonishing observation: This value is always prime or 1. For example:
    C(2)=1+2=3C(2)=1+2=3C(2)=1+2=3, ratio = 2 (prime).
    C(3)=3+3=6C(3)=3+3=6C(3)=3+3=6, ratio = 3 (prime).
    C(4)=6+lcm⁡(4,6)=6+12=18C(4)=6+\operatorname{lcm}(4,6)=6+12=18C(4)=6+lcm(4,6)=6+12=18, ratio = 2.
    C(5)=18+lcm⁡(5,18)=18+90=108C(5)=18+\operatorname{lcm}(5,18)=18+90=108C(5)=18+lcm(5,18)=18+90=108, ratio = 5.
    etc.

Open problem

No one has proved that this always holds. In 2015, Ruiz‑Cabello showed it is equivalent to a deep open question about primes in arithmetic progressions, making it much harder than the gcd recurrence proof.

Key Takeaways

  • The recurrence R(n)=R(n−1)+gcd⁡(n,R(n−1))R(n) = R(n-1) + \gcd(n, R(n-1))R(n)=R(n−1)+gcd(n,R(n−1)) with R(1)=7R(1)=7R(1)=7 generates a sequence where all nontrivial gcds are prime.

  • These primes appear in clusters with long runs of 1s between them.

  • The theorem provides a shortcut: the next prime gcd is the smallest prime divisor of 2n−12n-12n−1, appearing after (p−1)/2(p-1)/2(p−1)/2 steps.

  • The proof relies on the invariant R(n)=3nR(n) = 3nR(n)=3n that reoccurs after each jump.

  • The recurrence is not efficient for finding large primes (the shortcut requires primality testing).

  • Many open questions remain: Do all odd primes appear? Does every starting value ≥4\geq 4≥4 eventually yield the 3n3n3n invariant? The lcm variant remains a conjecture.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent