A306562 a(n) = 1 + 2 - 3 - 4 + 5 + 6 + 7 - 8 - 9 - 10 - 11 + 12 + 13 + 14 + 15 + ... + (+-1)*n, where, after the 1st summand there is one plus, two minuses, three plusses, etc.
1, 3, 0, -4, 1, 7, 14, 6, -3, -13, -24, -12, 1, 15, 30, 46, 29, 11, -8, -28, -49, -71, -48, -24, 1, 27, 54, 82, 111, 81, 50, 18, -15, -49, -84, -120, -157, -119, -80, -40, 1, 43, 86, 130, 175, 221, 174, 126, 77, 27, -24, -76, -129, -183, -238, -294, -237, -179
Offset: 0
Examples
a(0) = 1 = 1 a(1) = 1 + 2 = 3 a(2) = 1 + 2 - 3 = 0 a(3) = 1 + 2 - 3 - 4 = -4 a(4) = 1 + 2 - 3 - 4 + 5 = 1 a(5) = 1 + 2 - 3 - 4 + 5 + 6 = 7 a(6) = 1 + 2 - 3 - 4 + 5 + 6 + 7 = 14
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..10011 (first 1001 terms from Harvey P. Dale)
Programs
-
Maple
a:= proc(n) option remember: `if`(n=0, 1, a(n-1)+(n+1)*(-1)^floor(sqrt(2*n)-1/2)) end: seq(a(n), n=0..60); # Alois P. Heinz, Feb 26 2019
-
Mathematica
With[{nn=20},Accumulate[Flatten[Join[{1,2},Times@@@Partition[Riffle[TakeList[Range[3,3+(nn(nn+1))/2],Range[2,nn]],{-1,1}],2]]]]] (* Harvey P. Dale, Mar 24 2024 *)
-
Python
from math import isqrt def A306562(n): return 1+sum((k if isqrt(k-1<<3)+1&2 else -k) for k in range(2,n+2)) # Chai Wah Wu, Jun 07 2025
Formula
F(n) = ((-1)^(n+1)(2n+1)(2n^2+2n+5)+21)/16 gives local extrema 3, -4, 14, -24, 46, -71, 111, -157, ... (conjectured). - Jean-François Alcover, Jun 01 2019
For n > 0, a(n) = 1 + Sum_{k=1..n} (-1)^(A002024(k)+1)*(k+1). - Jinyuan Wang, Aug 06 2019
a(n) = 1 <=> n in { A046092 }. - Alois P. Heinz, Jun 08 2025
Extensions
New name from Michel Marcus, Apr 11 2019