OFFSET
1,2
LINKS
Nathaniel Johnston, Table of n, a(n) for n = 1..10000
EXAMPLE
Let prime(n) denote the n-th prime.
Because prime(1)=2, take first 2 odd numbers giving a(1)=1, a(2)=3.
Because prime(2)=3, take 3 even numbers starting with 4 giving a(3)=4, a(4)=6, a(5)=8.
Because prime(3)=5, take 5 odd numbers starting with 9 giving a(6)=9, a(7)=11, a(8)=13, a(9)=15, a(10)=17.
Because prime(4)=7, take 7 even numbers starting with 18 gives a(11)=18, a(12)=20, ..., a(17)=30 etc.
MAPLE
cp:=2:ct:=1:a := proc(n) option remember: global cp, ct: if(n=1)then return 1: elif(ct=cp)then ct:=1:cp:=nextprime(cp): return a(n-1)+1: else ct:=ct+1: return a(n-1)+2: fi: end: seq(a(n), n=1..100); # Nathaniel Johnston, Aug 11 2011
MATHEMATICA
nxt[{p_, a_}]:={NextPrime[p], Range[Last[a]+1, Last[a]+2*NextPrime[p], 2]}; Transpose[NestList[nxt, {2, {1, 3}}, 10]][[2]]//Flatten (* Harvey P. Dale, Mar 23 2016 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Ctibor O. Zizka, Aug 08 2011
STATUS
approved