OFFSET
1,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..442 (first 91 terms from N. J. A. Sloane)
MAPLE
b:= proc(n) option remember; (m->
`if`(isprime(m), ithprime(n)+1, 2*m-1))(b(n-1))
end: b(1):=2:
a:= proc(n) option remember; local k; for k from 1+a(n-1)
while not isprime(b(k)) do od; k
end: a(0):=0:
seq(a(n), n=1..62); # Alois P. Heinz, Aug 05 2024
MATHEMATICA
Reap[Module[{n = 1}, Nest[If[n++; PrimeQ[#], Sow[n-1]; Prime[n] + 1, 2*# - 1] &, 2, 1000]]][[2, 1]] (* Paolo Xausa, Aug 07 2024 *)
PROG
(Python)
from itertools import count
from sympy import isprime, nextprime
def A373803_gen(): # generator of terms
a, p = 2, 3
for i in count(1):
if isprime(a):
yield i
a = p+1
else:
a = (a<<1)-1
p = nextprime(p)
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Aug 05 2024
STATUS
approved