cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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).

This page as a plain text file.
%I A064520 #31 Jul 17 2025 12:44:01
%S A064520 1,-1,-4,0,5,11,4,-4,-13,-23,-12,0,13,27,42,26,9,-9,-28,-48,-69,-47,
%T A064520 -24,0,25,51,78,106,77,47,16,-16,-49,-83,-118,-154,-117,-79,-40,0,41,
%U A064520 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
%N 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).
%C A064520 |a(n)| takes its locally maximal values when n is a triangular number, the maximal values being given by A019298.
%C A064520 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, ...
%H A064520 Harry J. Smith, <a href="/A064520/b064520.txt">Table of n, a(n) for n = 1..1000</a>
%F A064520 a(n) = Sum_{k=1..n} (-1)^(A002024(k)+1)*k.
%e A064520 a(9) = -13 because 1 - 2 - 3 + 4 + 5 + 6 - 7 - 8 - 9 = -13.
%p A064520 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:
%t A064520 Accumulate[Flatten[Table[(-1)^(n+1) Range[(n(n-1))/2+1,(n(n+1))/2], {n,15}]]] (* _Harvey P. Dale_, Apr 22 2015 *)
%o A064520 (PARI) t(n) = floor(1/2+sqrt(2*n))
%o A064520 for(n=1,200,print1(sum(k=1,n,(-1)^(t(k)+1)*k)," "))
%o A064520 (PARI) t(n)= { floor(sqrt(2*n) + 1/2) }
%o A064520 { 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
%o A064520 (Python)
%o A064520 from math import isqrt
%o A064520 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
%Y A064520 Cf. A002024, A019298, A064528.
%K A064520 sign,look,easy
%O A064520 1,3
%A A064520 Jonathan Ayres (jonathan.ayres(AT)btinternet.com), Oct 07 2001
%E A064520 More terms from _James Sellers_, _Jason Earls_ and _Vladeta Jovovic_, Oct 08 2001