A373801 a(1) = 2; thereafter, if a(n-1) is prime then a(n) = prime(n) + 1; otherwise a(n) = 2*a(n-1) - 1.
2, 4, 7, 8, 15, 29, 18, 35, 69, 137, 32, 63, 125, 249, 497, 993, 1985, 3969, 7937, 72, 143, 285, 569, 90, 179, 102, 203, 405, 809, 114, 227, 132, 263, 140, 279, 557, 158, 315, 629, 1257, 2513, 5025, 10049, 20097, 40193, 200, 399, 797, 228, 455, 909, 1817, 3633, 7265, 14529, 29057, 58113, 116225
Offset: 1
Keywords
Links
- N. J. A. Sloane, Table of n, a(n) for n = 1..2000
- N. J. A. Sloane, A Nasty Surprise in a Sequence and Other OEIS Stories, Experimental Mathematics Seminar, Rutgers University, Oct 10 2024, Youtube video; Slides [Mentions this sequence]
Programs
-
Maple
A:=Array(1..1200,0); t:=2; A[1]:= t; for n from 2 to 100 do if isprime(t) then t:=ithprime(n)+1; else t:=2*t-1; fi; A[n]:=t; od: [seq(A[n],n=1..100)];
-
Mathematica
Module[{n = 1}, NestList[If[n++; PrimeQ[#], Prime[n] + 1, 2*# - 1] &, 2, 100]] (* Paolo Xausa, Aug 07 2024 *)
-
Python
from sympy import isprime, nextprime def A373801_gen(): # generator of terms a, p = 2, 3 while True: yield a a, p = p+1 if isprime(a) else (a<<1)-1, nextprime(p) A373801_list = list(islice(A373801_gen(),20)) # Chai Wah Wu, Aug 05 2024
Comments