OFFSET
1,2
COMMENTS
For each divisor d of n, add d if d is odd, otherwise add 1.
FORMULA
EXAMPLE
For n = 12, the divisors of 12 are 1, 2, 3, 4, 6, 12 with corresponding summands 1, 1, 3, 1, 1, 1, respectively. The sum is then a(12) = 1 + 1 + 3 + 1 + 1 + 1 = 8.
MATHEMATICA
a[n_] := DivisorSum[n, #^Mod[#, 2] &]; Array[a, 100] (* Amiram Eldar, Nov 04 2021 *)
PROG
(PARI) a(n) = sumdiv(n, d, if (d%2, d, 1)); \\ Michel Marcus, Nov 04 2021
(Python)
from math import prod
from sympy import factorint
def A348915(n):
f = factorint(n>>(m:=(~n&n-1).bit_length())).items()
d = prod(e+1 for p, e in f)
s = prod((p**(e+1)-1)//(p-1) for p, e in f)
return s+d*m # Chai Wah Wu, Jul 16 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Wesley Ivan Hurt, Nov 03 2021
STATUS
approved