11.4 Divisors

How do you compute the sum of the divisors of an integer in Sage?

Sage uses divisors(n) for the number (usually denoted $ d(n)$ ) of divisors of $ n$ and sigma(n,k) for the sum of the $ k-th$ powers of the divisors of $ n$ (so divisors(n) and sigma(n,0) are the same). For example:

sage: divisors(28); sum(divisors(28)); 2*28
[1, 2, 4, 7, 14, 28]
56
56
sage: sigma(28,0); sigma(28,1); sigma(28,2)
6
56
1050

See About this document... for information on suggesting changes.