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!)
A282886 Sum_{k=0..n} (-1)^issquare(p(k))*p(k) where p=A282840 is the lexicographic-first permutation of the nonnegative integers such that these sums always remain nonnegative. 4
0, 2, 1, 4, 0, 5, 11, 2, 9, 17, 1, 11, 22, 34, 9, 22, 36, 0, 15, 32, 50, 1, 20, 40, 61, 83, 19, 42, 66, 92, 11, 38, 66, 95, 125, 25, 56, 88, 121, 0, 34, 69, 106, 144, 0, 39, 79, 120, 162, 205, 36, 80, 125, 171, 218, 22, 70, 120, 171, 223, 276, 51, 105, 160, 216, 273, 17, 75, 134, 194, 255, 317, 28, 91, 156, 222, 289, 357, 33, 102, 172, 243, 315 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,2
COMMENTS
In short: subtract squares when you can, else add nonsquares.
A variant of A282846 (corresponding to permutation A282864) and A282865: In those variants, "square" is replaced by "prime".
The graph yields a nice moirée pattern.
LINKS
EXAMPLE
Starting from a(0)=0 we cannot subtract the square 1, so we add 2 to get a(1)=2, then we can subtract 1, a(2)=1. Now we must add nonsquare 3 to get a(3)=4 before subtracting the square 4, to yield zero sum a(4)=0. Now we have to add nonsquares 5, a(5)=5, and 6, a(6)=11, before subtracting the next square 9, a(7)=2. And so on.
MAPLE
a:= 1: b:= 2:
S[0]:= 0:
for n from 1 to 100 do
if S[n-1] - a^2 >= 0 then
S[n]:= S[n-1] - a^2; a:= a+1;
else S[n]:= S[n-1] + b; b:= b+1;
if issqr(b) then b:= b+1 fi
fi
od:
seq(S[i], i=0..100); # Robert Israel, Apr 15 2019
PROG
(PARI) {print1(a=0); c=1; p=2; for(n=1, 199, if(a<c^2, a+=p; while(issquare(p++), ), a-=c^2; c++); print1(", "a))}
CROSSREFS
Sequence in context: A324055 A087664 A158032 * A282846 A326129 A336566
KEYWORD
nonn,look
AUTHOR
M. F. Hasler and Eric Angelini, Feb 24 2017
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 March 28 08:22 EDT 2024. Contains 371236 sequences. (Running on oeis4.)