OFFSET
1,2
COMMENTS
a(n) = Sum_{k=1..n} (-1)^(sopfr(k)+1), with sopfr(n) the sum of the prime factors of n with repetition, also known as the integer log of n.
LINKS
Daniel Blaine McBride, Table of n, a(n) for n = 1..100000
K. Alladi and P. Erdős, On an additive arithmetic function, Pacific J. Math., Volume 71, Number 2 (1977), 275-294.
Eric Weisstein's World of Mathematics, Sum of Prime Factors
FORMULA
a(n) = a(n-1) + (-1)^(sopfr(n)+1) with a(1) = (-1)^(sopfr(1)+1) = -1.
EXAMPLE
a(4) = -1 - 1 + 1 - 1 = -2, since sopfr(1) = 0, sopfr(2) = 2, sopfr(3) = 3, and sopfr(4) = 4.
MATHEMATICA
Nest[Append[#, #[[-1]] + (-1)^(1 + Total@ Flatten[ConstantArray[#1, #2] & @@@ FactorInteger[Length@ # + 1] ])] &, {-1}, 79] (* Michael De Vlieger, Sep 10 2018 *)
PROG
(Python)
from sympy import factorint
def A318682(n):
....a_n = 0
....for i in range(1, n+1):
........a_n += (-1)**(sum(p*e for p, e in factorint(i).items())+1)
....return a_n
(PARI) sopfr(n) = my(f=factor(n)); sum(k=1, #f~, f[k, 1]*f[k, 2]);
a(n) = sum(k=1, n, (-1)^(sopfr(k)+1)); \\ Michel Marcus, Sep 09 2018
CROSSREFS
KEYWORD
sign
AUTHOR
Daniel Blaine McBride, Aug 30 2018
STATUS
approved