OFFSET
1,2
COMMENTS
Consider an operation SS(n) defined for a specific sequence b where b(n) is the n-th term of b. This operation is defined as follows: SS(1) = b(1); if b(n+1) > SS(n), SS(n+1) = SS(n) + b(n+1), otherwise SS(n+1) = SS(n) - b(n+1) (If b(n) = A000027(n), then SS(n) = A008344(n+1)). If the sequence b can represent any permutation of the first n natural numbers, then a(n) is the maximum possible value of SS(n). - Iain Fox, Sep 15 2020 (see link by Math StackExchage)
LINKS
Iain Fox, Table of n, a(n) for n = 1..10000
Math StackExchange, Strange Sum of Numbers 1 to 100, September 2020.
Index entries for linear recurrences with constant coefficients, signature (2,-2,2,-1).
FORMULA
G.f.: x*(1+x+2*x^3) / ( (1+x^2)*(x-1)^2 ). - R. J. Mathar, Oct 08 2011
a(n) = 2*(n-1)-(i^(n*(n+1))-1)/2, where i=sqrt(-1). - Bruno Berselli, Dec 06 2011
From Wesley Ivan Hurt, May 31 2016: (Start)
a(n) = 2*a(n-1) - 2*a(n-2) + 2*a(n-3) - a(n-4) for n>4.
a(n) = (1+i)*(4*n-4*n*i+3*i-3+i^(1-n)-i^n)/4 where i=sqrt(-1).
E.g.f.: (4 + sin(x) - cos(x) + (4*x - 3)*exp(x))/2. - Ilya Gutkovskiy, May 31 2016
Sum_{n>=1} (-1)^(n+1)/a(n) = 3*Pi/16 - (sqrt(2)+1)*log(2)/8 + sqrt(2)*log(sqrt(2)+2)/4. - Amiram Eldar, Dec 24 2021
MAPLE
MATHEMATICA
Select[Range[108], MemberQ[{1, 3, 4, 6}, Mod[#, 8]]&] (* Bruno Berselli, Dec 06 2011 *)
PROG
(Maxima) makelist(2*(n-1)-(%i^(n*(n+1))-1)/2, n, 1, 55); /* Bruno Berselli, Dec 06 2011 */
(PARI) a(n)=2*(n-1)-(I^(n*(n+1))-1)/2 \\ Charles R Greathouse IV, Dec 06 2011
(Magma) [n : n in [0..150] | n mod 8 in [1, 3, 4, 6]]; // Wesley Ivan Hurt, May 31 2016
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
STATUS
approved