login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

A377371
a(n) = k*(a(n-1)+n), k=-1 for prime n, otherwise k=1 (a(1)=1).
1
1, -3, 0, 4, -9, -3, -4, 4, 13, 23, -34, -22, 9, 23, 38, 54, -71, -53, 34, 54, 75, 97, -120, -96, -71, -45, -18, 10, -39, -9, -22, 10, 43, 77, 112, 148, -185, -147, -108, -68, 27, 69, -112, -68, -23, 23, -70, -22, 27, 77, 128, 180, -233, -179, -124, -68, -11
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
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
Sequence in context: A255504 A178593 A021332 * A008344 A088230 A181482
KEYWORD
sign,easy
AUTHOR
Bill McEachen, Dec 27 2024
STATUS
approved