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”).
%I #14 Dec 08 2024 04:00:55
%S 3,5,7,13,37,31,23,17,53,11,251,29,79,43,73,61,97,67,107,173,59,103,
%T 199,163,71,149,47,101,509,89,151,283,229,271,211,109,257,113,269,157,
%U 241,331,83,389,41,313,1543,19,307,463,373,277,811,457,137,191,419,311,197
%N a(n) is the smallest odd prime such that (1) a(n) doesn't already appear in the sequence; (2) the n-th partial sum is divisible by n; and (3) the n-th partial sum is relatively prime to n+1.
%C Condition (3) is needed to ensure that a(n+1) exists.
%H Robert Israel, <a href="/A075557/b075557.txt">Table of n, a(n) for n = 1..10000</a>
%e 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).
%p N:= 10000: # for terms until the first term > N.
%p Cands:= select(isprime, [seq(i,i=3..N,2)]):
%p nC:= nops(Cands):
%p R:= NULL: s:= 0:
%p for n from 1 do
%p found:= false;
%p for i from 1 to nC do
%p if s + Cands[i] mod n = 0 and igcd(s + Cands[i],n+1) = 1 then
%p R:= R, Cands[i];
%p s:= s + Cands[i];
%p Cands:= subsop(i=NULL,Cands);
%p nC:= nC-1;
%p found:= true;
%p break
%p fi
%p od;
%p if not found then break fi
%p od:
%p R; # _Robert Israel_, Dec 07 2024
%Y Cf. A065091 (odd primes).
%K nonn,easy,look
%O 1,1
%A _Amarnath Murthy_, Sep 24 2002
%E Edited by _David Wasserman_, Jun 27 2003
%E Corrected by _Robert Israel_, Dec 07 2024