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

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A064520 a(n) = + 1 - 2 - 3 + 4 + 5 + 6 - 7 - 8 - 9 - 10 + 11 + 12 + 13 + 14 + 15 - ... + (+-1)*n, where there is one plus, two minuses, three pluses, etc. (see A002024). 3
 1, -1, -4, 0, 5, 11, 4, -4, -13, -23, -12, 0, 13, 27, 42, 26, 9, -9, -28, -48, -69, -47, -24, 0, 25, 51, 78, 106, 77, 47, 16, -16, -49, -83, -118, -154, -117, -79, -40, 0, 41, 83, 126, 170, 215, 169, 122, 74, 25, -25, -76, -128, -181, -235, -290, -234, -177, -119, -60, 0, 61, 123, 186, 250, 315, 381, 314, 246, 177 (list; graph; refs; listen; history; text; internal format)
 OFFSET 1,3 COMMENTS |a(n)| takes its locally maximal values when n is a triangular number, the maximal values being given by A019298. The maximal positive/negative values occur for n = 1, 3, 6, 10, 15, 21 ... the triangular numbers and are a(n) = 1, -4, 11, -23, 42, -69,106, 215, 381, 616 ... +- int(sqrt(n^3/2) + 0.22098 * sqrt(n)). a(n) = n for n = 5, 13, 25, 41, 61, 85, ... m*(m*2-2)+1 and the previous number is equal to 0. Positive numbers which do not occur in this sequence are 2, 3, 6, 7, 8, 10, 12, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 43, 44, 45, 46, 48, ... LINKS Harry J. Smith, Table of n, a(n) for n = 1..1000 FORMULA a(n) = Sum_{k=1..n} (-1)^(A002024(k)+1)*k. EXAMPLE a(9) = -13 because 1 - 2 - 3 + 4 + 5 + 6 - 7 - 8 - 9 = -13. MAPLE a := proc(n) option remember: if n=1 then RETURN(1) fi: a(n-1) + n*(-1)^( floor(1/2 + sqrt(2*n)+1)); end: for n from 1 to 150 do printf(`%d, `, a(n)) od: MATHEMATICA Accumulate[Flatten[Table[(-1)^(n+1) Range[(n(n-1))/2+1, (n(n+1))/2], {n, 15}]]] (* Harvey P. Dale, Apr 22 2015 *) PROG (PARI) t(n) = floor(1/2+sqrt(2*n)) for(n=1, 200, print1(sum(k=1, n, (-1)^(t(k)+1)*k), " ")) (PARI) t(n)= { floor(sqrt(2*n) + 1/2) } { for (n=1, 1000, a=sum(k=1, n, (-1)^(t(k) + 1)*k); write("b064520.txt", n, " ", a) ) } \\ Harry J. Smith, Sep 17 2009 (Python) from math import isqrt def A064520(n): return sum(k if (isqrt(k<<3)+1>>1)&1 else -k for k in range(1, n+1)) # Chai Wah Wu, Oct 16 2022 CROSSREFS Cf. A002024, A019298, A064528. Sequence in context: A372274 A355921 A164108 * A267313 A108174 A134530 Adjacent sequences: A064517 A064518 A064519 * A064521 A064522 A064523 KEYWORD sign,look,easy AUTHOR Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Oct 07 2001 EXTENSIONS More terms from James A. Sellers, Jason Earls and Vladeta Jovovic, Oct 08 2001 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.

Last modified June 21 12:50 EDT 2024. Contains 373544 sequences. (Running on oeis4.)