login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A073884
a(1)=2. Let S(k) = sum of k terms. If S(n) is prime then a(n+1) is the smallest prime not included earlier else a(n+1) is the smallest composite number not included earlier.
1
2, 3, 5, 4, 6, 8, 9, 7, 10, 12, 14, 15, 16, 18, 20, 11, 21, 13, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 17, 50, 51, 52, 54, 55, 56, 57, 58, 60, 19, 62, 63, 64, 65, 66, 68, 69, 70, 23, 72, 74, 75, 29, 76, 77, 78, 80, 81, 82, 84, 85, 31
OFFSET
1,1
LINKS
MAPLE
P, C:= selectremove(isprime, [$2..100]):
np:= nops(P): nc:= nops(C):
ip:= 1: ic:= 0: t:= 2: R:= 2:
do
if isprime(t) then
ip:= ip+1;
if ip > np then break fi;
R:= R, P[ip];
t:= t + P[ip];
else
ic:= ic+1;
if ic > nc then break fi;
R:= R, C[ic];
t:= t + C[ic];
fi
od:
R; # Robert Israel, Oct 07 2024
CROSSREFS
Sequence in context: A073298 A073291 A073280 * A209293 A328021 A361504
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Aug 17 2002
EXTENSIONS
Corrected and extended by Sean A. Irvine, Nov 29 2009
Offset corrected by Robert Israel, Oct 09 2024
STATUS
approved