A348855 a(1) = 1. If a(n) is prime, a(n+1) = 2*a(n) + 1. If a(n) is not prime, a(n+1) = least prime not already in the sequence.
1, 2, 5, 11, 23, 47, 95, 3, 7, 15, 13, 27, 17, 35, 19, 39, 29, 59, 119, 31, 63, 37, 75, 41, 83, 167, 335, 43, 87, 53, 107, 215, 61, 123, 67, 135, 71, 143, 73, 147, 79, 159, 89, 179, 359, 719, 1439, 2879, 5759, 97, 195, 101, 203, 103, 207, 109, 219, 113, 227, 455
Offset: 1
Examples
a(1) = 1 is not prime, so a(2) = 2, the smallest prime not seen so far. Then a(3) = 2*2 + 1 = 5, a(4) = 2*5 + 1 = 11, and so on, generating the chain 2,5,11,23,47. 47 is not a term in A005384 since 2*47 + 1 = 95 is not prime, after which the sequence resets to 3, the least unused prime so far, from which the next chain 3,7,15 arises, and so on. As an irregular table (each row after the first beginning with a prime and ending with a nonprime), the sequence begins: 1; 2, 5, 11, 23, 47, 95; 3, 7, 15; 13, 27; 17, 35; 19, 39; 29, 59, 119; 31, 63; 37, 75; 41, 83, 167, 335; 43, 87; ...
Links
- Michael De Vlieger, Table of n, a(n) for n = 1..10751 (5000 chains).
- Chris K. Caldwell, Cunningham Chain (PrimePages, Prime Glossary).
- Wikipedia, Cunningham chain.
Programs
-
Mathematica
a[1]=1;a[n_]:=a[n]=If[PrimeQ@a[n-1],2a[n-1]+1,k=2;While[MemberQ[Array[a,n-1],k],k=NextPrime@k];k];Array[a,60] (* Giorgos Kalogeropoulos, Nov 02 2021 *)
-
Python
from sympy import isprime, nextprime def aupton(terms): alst, aset = [1], {1} while len(alst) < terms: if isprime(alst[-1]): an = 2*alst[-1] + 1 else: p = 2 while p in aset: p = nextprime(p) an = p alst.append(an); aset.add(an) return alst print(aupton(60)) # Michael S. Branicky, Nov 02 2021
Comments