login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A080220
a(1)=2; then if n is prime, a(n) is the smallest prime number greater than a(n-1), if n is composite a(n)=a(n-1)+1.
1
2, 3, 5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 31, 32, 37, 38, 39, 40, 41, 42, 43, 44, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 59, 60, 61, 62, 63, 64, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 97
OFFSET
1,1
COMMENTS
More generally, let b(1)>1, m >0, b(n) be the smallest integer > b(n-1) such that b(n) is prime if n is prime, then limit n ->infinity b(n)/n =L exists and b<L<b+1.
LINKS
FORMULA
There is a constant C such that limit n ->infinity a(n)/n = C =1.72...
MATHEMATICA
nxt[{n_, a_}]:={n+1, If[PrimeQ[n+1], NextPrime[a], a+1]}; NestList[nxt, {1, 2}, 80][[;; , 2]] (* Harvey P. Dale, Sep 13 2024 *)
PROG
(PARI) a(n)=if(n<2, 2, if(isprime(n), nextprime(a(n-1)+1), a(n-1)+1))
CROSSREFS
Sequence in context: A161873 A224517 A341534 * A028778 A284885 A094180
KEYWORD
nonn
AUTHOR
Benoit Cloitre, Feb 06 2003
STATUS
approved