login
Lexicographic first permutation of the nonnegative integers such that the partial sums of (-1)^isprime(a(n))*a(n) always remain nonnegative.
4

%I #7 Feb 23 2017 22:35:34

%S 0,1,4,2,3,6,5,8,7,9,11,10,12,13,14,17,15,19,16,18,23,20,29,21,22,31,

%T 24,37,25,26,41,27,28,43,30,47,32,33,53,34,35,59,36,61,38,39,67,40,42,

%U 71,44,45,73,46,79,48,49,83,50,51,89,52,54,97,55,56,101,57,103,58,60,107,62,63,109,64,65,113,66,68,127,69,70,131,72,137,74,75

%N Lexicographic first permutation of the nonnegative integers such that the partial sums of (-1)^isprime(a(n))*a(n) always remain nonnegative.

%C A variant of A282864, having the same definition except for opposite signs.

%o (PARI) {print1(s=0); c=1; p=2; for(n=1, 199, if(s>=p, a=-p; p=nextprime(p+1), a=c; while(isprime(c++),)); print1(","abs(a)); s+=a)}

%Y Cf. A282864, A282846.

%K nonn

%O 0,3

%A _M. F. Hasler_, Feb 23 2017