OFFSET
1,2
COMMENTS
From the infinitude of the primes, k<0 will always be seen, and the +/- halves of the graph are essentially mirror images. The number of sign changes through n should be on the order of primepi(n).
LINKS
Michael De Vlieger, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = a(n-1) + n for composite n, else -(a(n-1) + n).
EXAMPLE
a(1)=1. For n=2 (prime), a(2) = -(1+2) = -3. For n=3 (prime), a(3) = -(-3+3) = 0.
MATHEMATICA
j = 1; {j}~Join~Reap[Do[k = (1 - 2 Boole[PrimeQ[n]])*(j + n); j = Sow[k], {n, 2, 57}] ][[-1, 1]] (* Michael De Vlieger, Dec 28 2024 *)
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Bill McEachen, Dec 27 2024
STATUS
approved