login
Partial sums of (-1)^floor(n*e).
4

%I #12 Sep 08 2022 08:45:28

%S 1,0,1,2,1,2,1,0,1,0,-1,0,-1,0,1,0,1,2,1,2,1,0,1,0,-1,0,-1,0,1,0,1,2,

%T 1,2,1,0,1,0,1,2,1,2,3,2,3,2,1,2,1,0,1,0,1,2,1,2,3,2,3,2,1,2,1,0,1,0,

%U 1,2,1,2,3,2,3,2,1,2,1,2,3,2,3,4,3,4,3,2,3,2,1,2,1,2,3,2,3,4,3,4,3,2,3,2,1,2,1,2,3,2,3,2,1,2,1,0,1,0,1,2,1,2,3,2,3,2,1,2,1

%N Partial sums of (-1)^floor(n*e).

%H T. D. Noe, <a href="/A123739/b123739.txt">Table of n, a(n) for n = 1..10000</a>

%H Kevin O'Bryant, Bruce Reznick, and Monika Serbinowska, <a href="http://www.math.uiuc.edu/~reznick/ors.pdf">Almost alternating sums</a>, Amer. Math. Monthly, Vol. 113 (October 2006), 673-688.

%t Rest[FoldList[Plus,0,(-1)^Floor[E*Range[120]]]]

%t Accumulate[(-1)^Floor[E Range[200]]] (* _Harvey P. Dale_, May 06 2022 *)

%o (PARI) vector(50, n, sum(j=1,n, (-1)^(j\exp(-1))) ) \\ _G. C. Greubel_, Sep 05 2019

%o (Magma) [&+[(-1)^Floor(j*Exp(1)): j in [1..n]]: n in [1..130]]; // _G. C. Greubel_, Sep 05 2019

%o (Sage) [sum((-1)^floor(j*exp(1)) for j in (1..n)) for n in (1..130)] # _G. C. Greubel_, Sep 05 2019

%Y Cf. A123724 (sum for 2^(1/3)), A123737 (sum for sqrt(2)), A123738 (sum for pi).

%K easy,sign

%O 1,4

%A _T. D. Noe_, Oct 11 2006