OFFSET
1,8
COMMENTS
Number of odd nontrivial divisors of n minus number of even nontrivial divisors of n.
LINKS
David A. Corneth, Table of n, a(n) for n = 1..10000
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
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