login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A282888 Lexicographically earliest permutation p of the nonnegative integers such that Sum_{k=0..n} -(-1)^issquare(p(k))*p(k) is nonnegative for all n. 1
0, 1, 4, 2, 3, 9, 5, 16, 6, 7, 25, 8, 10, 11, 36, 12, 13, 14, 49, 15, 17, 64, 18, 19, 20, 21, 81, 22, 23, 24, 100, 26, 27, 28, 29, 121, 30, 31, 32, 33, 144, 34, 35, 37, 38, 169, 39, 40, 41, 42, 196, 43, 44, 45, 46, 225, 47, 48, 50, 51, 52, 256, 53, 54, 55, 56, 289, 57, 58, 59, 60, 61, 324, 62, 63, 65, 66, 67, 361, 68, 69, 70, 71, 72, 400, 73, 74, 75 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

In short: subtract nonsquares when you can, else add squares.

See A282887 for the partial (signed) sums.

A variant of A282840 (with partial sums A282886) and A282846 (corresponding to permutation A282864) and A282865; in the latter variants, "square" is replaced by "prime".

LINKS

Table of n, a(n) for n=0..87.

EXAMPLE

Starting from a(0)=0 we add the square a(1)=1, and since we cannot subtract the nonsquare 2, we also add the next larger square a(2)=4. Then we can subtract nonsquares a(3)=2 and a(4)=3. Now we must add the square a(5)=9 before subtracting the nonsquare a(6)=5. Again we must add the next larger square a(7)=16 before subtracting the nonsquares a(8)=6 and a(9)=7. And so on.

PROG

(PARI) {print1(a=0); c=1; p=2; for(n=1, 199, old=a; if(a>=p, a-=p; while(issquare(p++), ), a+=c^2; c++); print1(", "abs(old-a))}

CROSSREFS

Sequence in context: A321122 A143051 A297022 * A278101 A120240 A179394

Adjacent sequences:  A282885 A282886 A282887 * A282889 A282890 A282891

KEYWORD

nonn

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 | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 9 00:09 EDT 2021. Contains 343685 sequences. (Running on oeis4.)