

A282846


Start with a(0) = 0, c = 1, p = 2. Thereafter, if a(n) < c, then a(n+1) = a(n) + p and p is set to the next larger prime; else, a(n+1) = a(n)  c and c is set to the next larger composite number.


7



0, 2, 1, 4, 0, 5, 12, 6, 17, 9, 0, 13, 3, 20, 8, 27, 13, 36, 21, 5, 34, 16, 47, 27, 6, 43, 21, 62, 38, 13, 56, 30, 3, 50, 22, 75, 45, 13, 72, 39, 5, 66, 31, 98, 62, 24, 95, 56, 16, 89, 47, 3, 82, 37, 120, 74, 26, 115, 66, 16, 113, 62, 10, 111, 57, 2, 105, 49, 156, 99, 41, 150, 90, 28, 141, 78, 14, 141, 76, 10, 141, 73, 4, 141, 71, 210, 138, 64, 213
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,2


COMMENTS

First differences are primes and negative nonprimes; their absolute values yield a permutation of the positive integers.
See A282864 for the permutation of the nonnegative integers corresponding to the order in which the numbers are used in this sequence.


LINKS

M. F. Hasler, Table of n, a(n) for n = 0..10000 (a(0..5000) from JeanMarc Falcoz.)
E. Angelini, Le restaurant newyorkais, February 2017


MAPLE

P:=proc(q) local a, c, n, p; a:=0; c:=1; p:=2; print(a); for n from 1 to q do
if a<c then a:=a+p; p:=nextprime(p); else a:=ac; c:=c+1; while isprime(c) do c:=c+1; od; fi;
print(a); od; end: P(10^2); # Paolo P. Lava, Feb 23 2017


PROG

(PARI) A282846(n, s=0, a=0, c=1, p=2)={for(n=1, n, s&&print1(a", "); if(a<c, a+=p; p=nextprime(p+1), a=c; while(isprime(c++), ))); a} \\ Set 2nd argument s to 1 to print all intermediate terms.


CROSSREFS

Cf. A282864
Sequence in context: A087664 A158032 A282886 * A326129 A326144 A120112
Adjacent sequences: A282843 A282844 A282845 * A282847 A282848 A282849


KEYWORD

nonn,look


AUTHOR

Eric Angelini, JeanMarc Falcoz and M. F. Hasler, Feb 22 2017


STATUS

approved



