The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
The OEIS is supported by the many generous donors to the OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A181482 The sum of the first n integers, with every third integer taken negative. 4
 1, 3, 0, 4, 9, 3, 10, 18, 9, 19, 30, 18, 31, 45, 30, 46, 63, 45, 64, 84, 63, 85, 108, 84, 109, 135, 108, 136, 165, 135, 166, 198, 165, 199, 234, 198, 235, 273, 234, 274, 315, 273, 316, 360, 315, 361, 408, 360, 409, 459, 408, 460, 513, 459, 514, 570, 513, 571, 630 (list; graph; refs; listen; history; text; internal format)
 OFFSET 1,2 COMMENTS The partial sum for the first 10^k terms are 76, 57256, 55722556, 55572225556, 55557222255556,..., i.e., the palindrome 5{k}2{k-1}5{k} plus 1+2*10^(2*k-1). - R. J. Cano, Mar 10 2013, edited by M. F. Hasler, Mar 25 2013 LINKS Vincenzo Librandi, Table of n, a(n) for n = 1..1000 Wolfram Alpha, WA Query Index entries for linear recurrences with constant coefficients, signature (1,0,2,-2,0,-1,1). FORMULA From R. J. Mathar, Oct 23 2010: (Start) a(n) = a(n-1) + 2*a(n-3) - 2*a(n-4) - a(n-6) + a(n-7). G.f.: -x*(1+2*x+2*x^3+x^4-3*x^2) / ( (1+x+x^2)^2*(x-1)^3 ). a(n) = 2*A061347(n+1)/9 +4/9 + n*(n+1)/6 + 2*b(n)/3 where b(3k+1) = 0, b(3k) = -3k - 1 and b(3k+2) = 3k + 3. (End) a(n) = sum((i+1)*A131561(i), i=0..n-1) = A000217(n)-6*A000217(floor(n/3)). [Bruno Berselli, Dec 10 2010] a(0) = 0, a(n) = a(n-1) + (-1)^((n + 1) mod 3)*n - Jon Perry, Feb 17 2013 a(n) = n*(n+1)/2-3*floor(n/3)*(floor(n/3)+1). - R. J. Cano, Mar 01 2013 [Same as Berselli's formula. - Ed.] a(3k) = 3k(k-1)/2. - Jon Perry, Mar 01 2013 a(0) = 0, a(n) = a(n-1) + (1 - ((n+1) mod 3 mod 2) * 2) * n. - Jon Perry, Mar 03 2013 EXAMPLE a(7) = 1 + 2 - 3 + 4 + 5 - 6 + 7 = 10. MATHEMATICA a[n_] := Sum[If[Mod[j, 3] == 0, -j, j], {j, 1, n}]; Table[a[i], {i, 1, 50, 1}] (* Jon Perry *) tri[n_] := n (n + 1)/2; f[n_] := tri@ n - 6 tri@ Floor[n/3]; Array[f, 63] (* Robert G. Wilson v, Oct 24 2010 *) CoefficientList[Series[-(1 + 2*x + 2*x^3 + x^4 - 3*x^2)/((1 + x + x^2)^2*(x - 1)^3), {x, 0, 30}], x] (* Vincenzo Librandi, Feb 17 2013 *) Table[Sum[k * (-1)^Boole[Mod[k, 3] == 0], {k, n}], {n, 60}] (* Alonso del Arte, Feb 24 2013 *) With[{nn=20}, Accumulate[Times@@@Partition[Riffle[Range[3nn], {1, 1, -1}], 2]]] (* Harvey P. Dale, Feb 09 2015 *) PROG (JavaScript) c = 0; for (i = 1; i < 100; i++) {c += Math.pow(-1, (i + 1) % 3)*i; document.write(c, ", "); } // Jon Perry, Feb 17 2013 (JavaScript) c=0; for (i = 1; i < 100; i++) { c += (1 - (i + 1) % 3 % 2 * 2) * i; document.write(c + ", "); } // Jon Perry, Mar 03 2013 (Magma) I:=[1, 3, 0, 4, 9, 3, 10]; [n le 7 select I[n] else Self(n-1)+2*Self(n-3)-2*Self(n-4)-Self(n-6)+Self(n-7): n in [1..60]]; // Vincenzo Librandi, Feb 17 2013 (PARI) a(n)=sum(k=1, n, k*((-1)^(k%3==0)) ) \\ R. J. Cano, Feb 26 2013 (PARI) a(n)={my(y=n\3); n*(n+1)\2-3*y*(y+1)} \\ R. J. Cano, Feb 28 2013 (Haskell) a181482 n = a181482_list !! (n-1) a181482_list = scanl1 (+) \$ zipWith (*) [1..] \$ cycle [1, 1, -1] -- Reinhard Zumkeller, Nov 23 2014 CROSSREFS Cf. A213203, A000217. Sequence in context: A021332 A008344 A088230 * A330420 A072329 A068630 Adjacent sequences: A181479 A181480 A181481 * A181483 A181484 A181485 KEYWORD nonn,easy AUTHOR Jon Perry, Oct 23 2010 EXTENSIONS More terms added by R. J. Mathar, Oct 23 2010 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 May 18 16:32 EDT 2024. Contains 372664 sequences. (Running on oeis4.)