login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A335021
a(n) = Sum_{d|n, 1 < d < n} (-1)^(d + 1).
2
0, 0, 0, -1, 0, 0, 0, -2, 1, 0, 0, -2, 0, 0, 2, -3, 0, 0, 0, -2, 2, 0, 0, -4, 1, 0, 2, -2, 0, 0, 0, -4, 2, 0, 2, -3, 0, 0, 2, -4, 0, 0, 0, -2, 4, 0, 0, -6, 1, 0, 2, -2, 0, 0, 2, -4, 2, 0, 0, -4, 0, 0, 4, -5, 2, 0, 0, -2, 2, 0, 0, -6, 0, 0, 4, -2, 2, 0, 0, -6, 3, 0, 0, -4, 2, 0, 2, -4
OFFSET
1,8
COMMENTS
Number of odd nontrivial divisors of n minus number of even nontrivial divisors of n.
LINKS
FORMULA
G.f.: Sum_{k>=2} (-1)^(k + 1) * x^(2*k) / (1 - x^k).
G.f.: - Sum_{k >= 2} x^(2*k)/(1 + x^k). - Peter Bala, Jan 12 2021
a(n) = A001227(n)*(1 - A007814(n)) - 1 + (-1)^n, if n > 1. - Sebastian Karlsson, Jan 14 2021
MATHEMATICA
Table[DivisorSum[n, (-1)^(# + 1) &, 1 < # < n &], {n, 1, 88}]
nmax = 88; CoefficientList[Series[Sum[(-1)^(k + 1) x^(2 k)/(1 - x^k), {k, 2, nmax}], {x, 0, nmax}], x] // Rest
PROG
(PARI) a(n) = sumdiv(n, d, if ((d>1) && (d<n), (-1)^(d + 1))); \\ Michel Marcus, May 20 2020
(Python)
from sympy import divisor_count
def A335021(n): return 0 if n == 1 else (1-(m:=(~n & n-1).bit_length()))*divisor_count(n>>m)-((n&1)<<1) # Chai Wah Wu, Jul 01 2022
CROSSREFS
KEYWORD
sign,easy
AUTHOR
Ilya Gutkovskiy, May 19 2020
STATUS
approved