login
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.
0
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,2
COMMENTS
The sequence exhibits consecutive terms of "nearly doubled primes", namely Cunningham Chains (of the first kind), the first of which is 2,5,11,23,47. Each prime in such a chain, except for the last is a term in A005384, and each prime except the first is a term in A005385. Every chain is terminated by composite number m = 2*q + 1, where q is the last prime in the chain. At this point the sequence resets to the smallest prime which has not yet been seen, from which the next chain is propagated, and so on. Since by definition every prime appears, so does every possible Cunningham chain. A similar (companion) sequence can be defined using a(n+1) = 2*a(n) - 1 for a(n) a prime term.
LINKS
Chris K. Caldwell, Cunningham Chain (PrimePages, Prime Glossary).
Wikipedia, Cunningham chain.
EXAMPLE
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; ...
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
STATUS
approved