Divisor sum (source code)

= Divisor sum
{title2=$F(n)=\sum_{d\mid n}f(d)$}

The <divisor sum> of an <arithmetic function> $f$ assigns to each <positive integer> $n$ the <sum>
$$
F(n)=\sum_{d\mid n}f(d).
$$
Only positive <integer divisors> are included, so $F(1)=f(1)$. The weights $f(d)$ can count the <integer divisors>, measure their sizes, or record other arithmetic information: the <constant-one arithmetic function> gives the <divisor function>, whereas the <identity arithmetic function> gives the <sum-of-divisors function>.

Equivalently, $F=f*\mathbf1$, where $*$ is <Dirichlet convolution> and $\mathbf1$ is the <constant-one arithmetic function>. If $f$ is a <multiplicative function>, then $F$ is a <multiplicative function> by <Multiplicativity of Dirichlet convolution>. https://darijgrinberg.gitlab.io/floor.pdf[Darij Grinberg, MIT 18.781 notes on floor and arithmetic functions, Proposition 2.4.2 and Theorem 2.6.1]{ref}

Here is the mechanism. For positive <coprime integers> $m,n$, every positive <integer divisor> of $mn$ has a unique form $ab$ with $a\mid m$ and $b\mid n$; moreover, $a,b$ are <coprime integers>. Thus a <multiplicative function> satisfies
$$
F(mn)=\sum_{a\mid m}\sum_{b\mid n}f(a)f(b)=F(m)F(n).
$$
At a <prime power>, the <divisor sum> becomes $F(p^a)=f(1)+f(p)+\cdots+f(p^a)$. This turns a calculation over many <integer divisors> into short local calculations at <prime powers>.