OFFSET
1,2
COMMENTS
This is the sequence S_1 mentioned in A141436. The primes and nonprimes alternate.
MAPLE
P:=n->ithprime(n);
# let b1 be a list of the nonprimes (from the b-file for A018252)
N:=n->if n<=nops(b1) then b1[n] else 0; fi;;
f:=proc(m) local S, n, sw, t; global P, N;
S:=[m]; t:=m;
if isprime(m) then sw:=1; else sw:=2; fi;
if sw=1 then
for n from 2 to 60 do
if n mod 2 = 0 then t:=N(t); if t=0 then return(S); fi; else t:=P(t); fi; S:=[op(S), t];
od:
else
for n from 2 to 60 do
if n mod 2 = 0 then t:=P(t); else t:=N(t); if t=0 then return(S); fi; fi; S:=[op(S), t];
od:
fi;
S;
end;
f(1); # A280028
f(3); # A280029
f(5); # A280030
MATHEMATICA
nonPrime[n_Integer] := FixedPoint[n + PrimePi@# &, n + PrimePi@ n]; a[n_] := If[ OddQ@ n, nonPrime[ a[n -1]], Prime@a[n -1]]; a[1] = 1; Array[a, 26] (* Robert G. Wilson v, Dec 28 2016 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Dec 25 2016
EXTENSIONS
a(13)-a(27) from Hans Havermann, Dec 25 2016
a(28) from Chai Wah Wu, Dec 26 2016
STATUS
approved