DivisorSigma[k,n]
gives the divisor function
.
DivisorSigma
DivisorSigma[k,n]
gives the divisor function
.
Details and Options
- DivisorSigma is also known as the divisor function or sum‐of‐divisors function.
- Integer mathematical function, suitable for both symbolic and numerical manipulation.
- DivisorSigma[k,n] is the sum of the k
powers of the divisors of n. - For a number
with
a unit and
primes, DivisorSigma[k,n] returns 
. - With the setting GaussianIntegers->True, DivisorSigma includes divisors that are Gaussian integers.
- DivisorSigma[k,m+In] automatically works over Gaussian integers.
Examples
open all close allBasic Examples (2)
Divisors[20]DivisorSigma[1, 20]The sum of squares of divisors:
DivisorSigma[2, 20]Plot DivisorSigma with log-scaled values:
DiscretePlot[{DivisorSigma[0, n], DivisorSigma[1, n], DivisorSigma[2, n]}, {n, 50}, ...]Scope (12)
Numerical Evaluation (4)
DivisorSigma works over integers:
DivisorSigma[2, 6]DivisorSigma[-2, 10]DivisorSigma[1 / 2, 12]DivisorSigma[1, 3 + I]DivisorSigma[2, 6, GaussianIntegers -> True]DivisorSigma[2, 10 ^ 30]DivisorSigma threads elementwise over lists:
DivisorSigma[2, {1, 2, 3, 4, 5}]Symbolic Manipulation (8)
TraditionalForm formatting:
DivisorSigma[k, n]//TraditionalFormReduce[DivisorSigma[1, n] == 3n && 0 < n < 4000, n, Integers]Solve[DivisorSigma[2, n] == n ^ 2 + 1 && 0 < n < 10, n, Integers]FullSimplify[DivisorSigma[1, 2 ^ (p - 1)(2 ^ p - 1)], Element[2 ^ p - 1, Primes]]FullSimplify[DivisorSigma[0, n] < EulerPhi[n], n∈Integers && n > 30]Use DivisorSigma in a sum:
Sum[DivisorSigma[0, n] / n ^ s, {n, Infinity}]DirichletTransform[DivisorSigma[k, n], s, n]Compute for symbolic arguments:
DivisorSigma[k, 30]Sum[DivisorSigma[k, n] / n ^ s, {n, Infinity}]Options (1)
Applications (13)
Basic Applications (3)
In general, DivisorSigma[d,n]=∑k|nkd:
Table[{DivisorSigma[d, 2 ^ 12 - 1], Sum[k ^ d, {k, Divisors[2 ^ 12 - 1]}]}, {d, 0, 5}]//GridThe ratio of Gaussian divisors to integer divisors:
ListPlot[Table[DivisorSigma[0, n, GaussianIntegers -> True] / DivisorSigma[0, n], {n, 200}], Filling -> Axis]Plot DivisorSigma with log-scaled values:
DiscretePlot[{DivisorSigma[0, n], DivisorSigma[1, n], DivisorSigma[2, n]}, {n, 50}, ...]Special Sequences (4)
Recognize perfect numbers, numbers n such that the sum of their divisors is equal to
:
Select[Range[30], DivisorSigma[1, #] == 2#&]Deficient numbers, numbers n such that the sum of their divisors is smaller than
:
Select[Range[30], DivisorSigma[1, #] < 2#&]Abundant numbers, numbers n such that the sum of their divisors is greater than
:
Select[Range[30], DivisorSigma[1, #] > 2#&]Recognize highly composite numbers: [more info]
highlyCompositeQ[n_] := Length[Select[Range[n - 1], DivisorSigma[0, #] ≥ DivisorSigma[0, n]&]] == 0;Select[Range[20], highlyCompositeQ]Recognize amicable numbers, two different numbers such that the sum of the proper divisors of each is equal to the other number:
amicablePairQ[n_, m_] := DivisorSigma[1, n] - n == m && DivisorSigma[1, m] - m == n;amicablePairQ[220, 284]amicablePairQ[10, 4]Recognize
-multiperfect numbers, numbers such that the sum of their divisors is equal to
:
kPerfectQ[k_, n_] := DivisorSigma[1, n] == k n;The first
-perfect number is
:
kPerfectQ[3, 120]Numbers that are
-perfect are called perfect numbers:
kPerfectQ[2, 6]Number Theory (6)
If n is a power of
, then the sum of the divisors of n equals
, which makes n almost perfect:
n = 2 ^ 10;
{DivisorSigma[1, n], 2 n - 1}The number of the divisors is odd if and only if the number is a perfect square:
DivisorSigma[0, #]&@{2, 3, 5, 6, 7, 8, 10}DivisorSigma[0, #]&@{1, 4, 9}Compare the number of divisors with Euler's totient function:
DiscretePlot[{EulerPhi[n], DivisorSigma[0, n]}, {n, 50}, Rule[...]]Plot the running average of the number of divisors with its asymptotic value:
Show[ListPlot[Table[Sum[DivisorSigma[0, i], {i, n}] / n, {n, 50}]], Plot[Log[n] + 2EulerGamma - 1, {n, 1, 50}]]Compute an iterated aliquot sum:
NestList[DivisorSigma[1, #] - #&, 276, 20]ListLinePlot[Log[10, NestList[DivisorSigma[1, #] - #&, 276, 100]]]Show the evolution of the limit
:
ListLinePlot[Table[Table[Log[DivisorSigma[n, n + m] / DivisorSigma[n, n]], {n, 100}], {m, 5}]]Properties & Relations (6)
DivisorSigma is the sum of the
powers of the divisors:
Total[Divisors[100] ^ 5]DivisorSigma[5, 100]Use DivisorSum to find the sum of divisors:
DivisorSum[100, # ^ 5&]DivisorSigma is a multiplicative function:
DivisorSigma[3, 18] DivisorSigma[3, 25] == DivisorSigma[3, 18 25]The reciprocals of the divisors of a perfect number n must add up to
:
PerfectNumberQ[28]DivisorSigma[-1, 28]The sum of divisors of a prime power n is less than 2n:
(DivisorSigma[1, #] < 2#) & /@ Select[Range[100], PrimePowerQ]For a prime number p, the number of the divisors is
:
p = RandomPrime[100];DivisorSigma[0, p] == 2DivisorSigma[1, p] == p + 1The number of divisors of
is
:
n = 5;
DivisorSigma[0, p ^ n] == n + 1Use DivisorSigma to find the product of divisors:
a = 24;
Product[d, {d, Divisors[a]}]a ^ (1 / 2DivisorSigma[0, a])Possible Issues (1)
With GaussianIntegers->True, the naive definition does not give the correct result:
DivisorSigma[2, 100, GaussianIntegers -> True]Total[Divisors[100, GaussianIntegers -> True] ^ 2]To make DivisorSigma a multiplicative function, a definition involving factors is used:
Times@@((#1 ^ ((#2 + 1)2) - 1) / (#1 ^ 2 - 1)&@@@({Select[#1 {1, -1, I, -I}, (Re[#] > 0 && Im[#] > 0)&][[1]], #2}&@@@FactorInteger[100, GaussianIntegers -> True]))Neat Examples (4)
Plot the arguments of the Fourier transform of DivisorSigma:
ArrayPlot[Arg[Fourier[Table[DivisorSigma[m, n], {m, 100}, {n, 100}]]], ColorFunction -> Hue]Plot the absolute values of the Fourier transform of DivisorSigma:
ArrayPlot[Abs[Fourier[Table[DivisorSigma[m, n], {m, 100}, {n, 100}]]], ColorFunction -> Hue]Plot the arguments of the Fourier transform of DivisorSigma:
ArrayPlot[Arg[Fourier[Table[If[x + I y == 0, 0, DivisorSigma[4, x + I y, GaussianIntegers -> True]], {x, 0, 128}, {y, 0, 128}]]], ColorFunction -> "Rainbow"]Plot the Ulam spiral of the mean of the divisors:
ulam[n_] := Partition[Permute[Range[n ^ 2], Accumulate[Take[Flatten[{{n ^ 2 + 1} / 2, Table
[(-1) ^ j i, {j, n}, {i, {-1, n}}, {j}]}], n ^ 2]]], n];ArrayPlot[DivisorSigma[0, ulam[71]], ColorFunction -> "Rainbow"]Tech Notes
Related Links
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), DivisorSigma, Wolfram Language function, https://reference.wolfram.com/language/ref/DivisorSigma.html.
CMS
Wolfram Language. 1988. "DivisorSigma." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DivisorSigma.html.
APA
Wolfram Language. (1988). DivisorSigma. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DivisorSigma.html
BibTeX
@misc{reference.wolfram_2026_divisorsigma, author="Wolfram Research", title="{DivisorSigma}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/DivisorSigma.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_divisorsigma, organization={Wolfram Research}, title={DivisorSigma}, year={1988}, url={https://reference.wolfram.com/language/ref/DivisorSigma.html}, note=[Accessed: 12-June-2026]}