A175792 a(n) = Sum_{k=1..n} (-1)^A000796(k), excess of the number of even over odd digits in the first n digits of Pi.
-1, -2, -1, -2, -3, -4, -3, -2, -3, -4, -5, -4, -5, -6, -7, -8, -7, -8, -7, -6, -5, -4, -3, -2, -3, -4, -3, -4, -3, -4, -5, -6, -5, -4, -3, -2, -1, -2, -3, -4, -5, -4, -5, -6, -7, -8, -9, -10, -11, -12, -11, -12, -11, -10, -9, -10, -11, -10, -11, -10, -9, -10, -11, -10
Offset: 1
Examples
a(6) = (-1)^3 + (-1)^1 + (-1)^4 + (-1)^1 + (-1)^5 + (-1)^9= -4.
Programs
-
Maple
Digits := 100: A000796 := proc(n) floor(Pi*10^(n-1)) mod 10; end proc: A175792 := proc(n) add((-1)^A000796(k),k=1..n) ; end proc: # R. J. Mathar, Jul 10 2012
-
Mathematica
Rest@ FoldList[ Plus, 0, (-1)^First@ RealDigits[Pi, 10, 200]] Accumulate[Table[If[EvenQ[n],1,-1],{n,RealDigits[Pi,10,70][[1]]}]] (* Harvey P. Dale, Nov 03 2015 *)
Comments