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”).

A280028
a(1)=1; thereafter, if n even, a(n) = a(n-1)-st prime, and if n odd, a(n) = a(n-1)-st nonprime.
4
1, 2, 4, 7, 12, 37, 52, 239, 301, 1993, 2338, 20753, 23356, 266587, 291968, 4134187, 4446630, 75947059, 80652283, 1625456353, 1710094788, 39954587527, 41737658509, 1114336791787, 1157634258442, 34900173534517, 36096139358620, 1216553712004063
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