This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A348855 #17 Jul 02 2025 22:15:08 %S A348855 1,2,5,11,23,47,95,3,7,15,13,27,17,35,19,39,29,59,119,31,63,37,75,41, %T A348855 83,167,335,43,87,53,107,215,61,123,67,135,71,143,73,147,79,159,89, %U A348855 179,359,719,1439,2879,5759,97,195,101,203,103,207,109,219,113,227,455 %N 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. %C A348855 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. %H A348855 Michael De Vlieger, <a href="/A348855/b348855.txt">Table of n, a(n) for n = 1..10751</a> (5000 chains). %H A348855 Chris K. Caldwell, <a href="https://primes.utm.edu/glossary/page.php?sort=CunninghamChain">Cunningham Chain</a> (PrimePages, Prime Glossary). %H A348855 Wikipedia, <a href="https://en.wikipedia.org/wiki/Cunningham_chain">Cunningham chain</a>. %e A348855 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. %e A348855 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. %e A348855 As an irregular table (each row after the first beginning with a prime and ending with a nonprime), the sequence begins: %e A348855 1; %e A348855 2, 5, 11, 23, 47, 95; %e A348855 3, 7, 15; %e A348855 13, 27; %e A348855 17, 35; %e A348855 19, 39; %e A348855 29, 59, 119; %e A348855 31, 63; %e A348855 37, 75; %e A348855 41, 83, 167, 335; %e A348855 43, 87; ... %t A348855 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 *) %o A348855 (Python) %o A348855 from sympy import isprime, nextprime %o A348855 def aupton(terms): %o A348855 alst, aset = [1], {1} %o A348855 while len(alst) < terms: %o A348855 if isprime(alst[-1]): %o A348855 an = 2*alst[-1] + 1 %o A348855 else: %o A348855 p = 2 %o A348855 while p in aset: p = nextprime(p) %o A348855 an = p %o A348855 alst.append(an); aset.add(an) %o A348855 return alst %o A348855 print(aupton(60)) # _Michael S. Branicky_, Nov 02 2021 %Y A348855 Cf. A000040, A005384, A338945, A075712. %K A348855 nonn,tabf %O A348855 1,2 %A A348855 _David James Sycamore_, Nov 01 2021