login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A096070 a(n) = least k > 0 not occurring earlier such that n-th partial sum is prime iff n is even. 3
1, 2, 3, 5, 4, 8, 7, 11, 9, 17, 10, 6, 12, 14, 13, 15, 16, 20, 19, 31, 21, 25, 18, 24, 22, 26, 23, 27, 28, 30, 29, 45, 32, 34, 33, 37, 35, 39, 38, 40, 36, 42, 41, 43, 44, 52, 46, 48, 47, 49, 51, 53, 50, 56, 54, 60, 55, 65, 57, 69, 58, 68, 59, 67, 61, 77, 62, 72, 63, 87, 64, 74 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
EXAMPLE
n = 4 is even, 5 is the least number not occurring earlier that makes fourth partial sum prime: 1+2+3+5 = 11. n = 5 is odd, 4 is the least number not occurring earlier that makes fifth partial sum nonprime: 1+2+3+5+4 = 15.
MAPLE
N:= 100: # terms until the first term > N
R:= NULL: S:= [$1..N]: s:= 0: found:= true;
for n from 1 while found do
found:= false;
for i from 1 to nops(S) do
if isprime(S[i]+s) xor n::odd then
found:= true; R:= R, S[i]; s:= s + S[i]; S:= subsop(i=NULL, S); break
fi
od od:
R; # Robert Israel, Sep 13 2020
MATHEMATICA
Module[{n, m = 72, s = 0, v = {}}, Reap[For[n = 1, n <= m, n++, k = 1; While[MemberQ[v, k] || PrimeQ[s+k] != EvenQ[n], k++]; Sow[k]; s = s+k; v = Union[v, {k}]]][[2, 1]]] (* Jean-François Alcover, Nov 03 2020, after PARI *)
PROG
(PARI) {m=72; s=0; v=Set([]); for(n=1, m, k=1; while(setsearch(v, k)>0||isprime(s+k)!=(n%2==0), k++); print1(k, ", "); s=s+k; v=setunion(v, Set(k)))}
CROSSREFS
Sequence in context: A048673 A288119 A292575 * A075157 A183080 A183082
KEYWORD
nonn
AUTHOR
Amarnath Murthy, Jun 20 2004
EXTENSIONS
Edited, corrected and extended by Klaus Brockhaus, Jun 21 2004
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 04:42 EDT 2024. Contains 371964 sequences. (Running on oeis4.)