OFFSET
1,1
COMMENTS
Condition (3) is needed to ensure that a(n+1) exists.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(5)=37: The 4th partial sum is 28. 7 is the smallest odd prime that satisfies (2) (28+7=35), but 7 has already been used. 17 satisfies (1) and (2) (28+17=45), but 45+a(6) must be a multiple of 6 and the only odd prime satisfying that requirement is 3, which has already been used. 37 works (28+37=65).
MAPLE
N:= 10000: # for terms until the first term > N.
Cands:= select(isprime, [seq(i, i=3..N, 2)]):
nC:= nops(Cands):
R:= NULL: s:= 0:
for n from 1 do
found:= false;
for i from 1 to nC do
if s + Cands[i] mod n = 0 and igcd(s + Cands[i], n+1) = 1 then
R:= R, Cands[i];
s:= s + Cands[i];
Cands:= subsop(i=NULL, Cands);
nC:= nC-1;
found:= true;
break
fi
od;
if not found then break fi
od:
R; # Robert Israel, Dec 07 2024
CROSSREFS
KEYWORD
AUTHOR
Amarnath Murthy, Sep 24 2002
EXTENSIONS
Edited by David Wasserman, Jun 27 2003
Corrected by Robert Israel, Dec 07 2024
STATUS
approved