Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.
%I #42 Feb 18 2024 07:57:51
%S 1,3,4,6,9,11,12,14,17,19,20,22,25,27,28,30,33,35,36,38,41,43,44,46,
%T 49,51,52,54,57,59,60,62,65,67,68,70,73,75,76,78,81,83,84,86,89,91,92,
%U 94,97,99,100,102,105,107,108,110,113,115,116,118,121,123,124
%N Numbers that are congruent to {1, 3, 4, 6} mod 8.
%C 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)
%H Iain Fox, <a href="/A047415/b047415.txt">Table of n, a(n) for n = 1..10000</a>
%H Math StackExchange, <a href="https://math.stackexchange.com/questions/3819559/strange-sum-of-numbers-1-to-100">Strange Sum of Numbers 1 to 100</a>, September 2020.
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (2,-2,2,-1).
%F G.f.: x*(1+x+2*x^3) / ( (1+x^2)*(x-1)^2 ). - _R. J. Mathar_, Oct 08 2011
%F a(n) = 2*(n-1)-(i^(n*(n+1))-1)/2, where i=sqrt(-1). - _Bruno Berselli_, Dec 06 2011
%F From _Wesley Ivan Hurt_, May 31 2016: (Start)
%F a(n) = 2*a(n-1) - 2*a(n-2) + 2*a(n-3) - a(n-4) for n>4.
%F a(n) = (1+i)*(4*n-4*n*i+3*i-3+i^(1-n)-i^n)/4 where i=sqrt(-1).
%F a(2*k) = A047398(k), a(2*k-1) = A047461(k). (End)
%F E.g.f.: (4 + sin(x) - cos(x) + (4*x - 3)*exp(x))/2. - _Ilya Gutkovskiy_, May 31 2016
%F 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
%p A047415:=n->2*(n-1)-(I^(n*(n+1))-1)/2: seq(A047415(n), n=1..100); # _Wesley Ivan Hurt_, May 31 2016
%t Select[Range[108], MemberQ[{1, 3, 4, 6}, Mod[#, 8]]&] (* _Bruno Berselli_, Dec 06 2011 *)
%o (Maxima) makelist(2*(n-1)-(%i^(n*(n+1))-1)/2, n, 1, 55); /* _Bruno Berselli_, Dec 06 2011 */
%o (PARI) a(n)=2*(n-1)-(I^(n*(n+1))-1)/2 \\ _Charles R Greathouse IV_, Dec 06 2011
%o (Magma) [n : n in [0..150] | n mod 8 in [1, 3, 4, 6]]; // _Wesley Ivan Hurt_, May 31 2016
%Y Cf. A008344, A047398, A047461.
%K nonn,easy
%O 1,2
%A _N. J. A. Sloane_