OFFSET
1,5
COMMENTS
a(n) < 0 for infinitely many values of n. - Benoit Cloitre, Jun 24 2002
First negative value is a(2946) = -1, which is for prime 26861. - David W. Wilson, Sep 27 2002
REFERENCES
Stan Wagon, The Power of Visualization, Front Range Press, 1994, p. 2.
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 1..20000 (first 10000 terms from T. D. Noe)
FORMULA
a(n) = Sum_{k=2..n} (-1)^((prime(k)+1)/2). - Benoit Cloitre, Jun 24 2002
a(n) = (Sum_{k=1..n} prime(k) mod 4) - 2*n (assuming that x mod 4 > 0). - Thomas Ordowski, Sep 21 2012
From Antti Karttunen, Oct 01 2017: (Start)
(End)
From Ridouane Oudra, Nov 04 2024: (Start)
a(n) = Sum_{k=2..n} i^(prime(k)+1), where i is the imaginary unit.
a(n) = Sum_{k=2..n} sin(3*prime(k)*Pi/2).
a(n) = Sum_{k=2..n} A163805(prime(k)).
a(n) = Sum_{k=2..n} A212159(k). (End)
MAPLE
ans:=[0]; ct:=0; for n from 2 to 2000 do
p:=ithprime(n); if (p mod 4) = 3 then ct:=ct+1; else ct:=ct-1; fi;
ans:=[op(ans), ct]; od: ans; # N. J. A. Sloane, Jun 24 2016
MATHEMATICA
FoldList[Plus, 0, Mod[Prime[Range[2, 110]], 4] - 2]
Join[{0}, Accumulate[If[Mod[#, 4]==3, 1, -1]&/@Prime[Range[2, 110]]]] (* Harvey P. Dale, Apr 27 2013 *)
PROG
(PARI) for(n=2, 100, print1(sum(i=2, n, (-1)^((prime(i)+1)/2)), ", "))
CROSSREFS
KEYWORD
AUTHOR
STATUS
approved