sigma: Divisor Functions

Description Usage Arguments Details Value Note References See Also Examples

Description

Sum of powers of all divisors of a natural number.

Usage

1
2
3
Sigma(n, k = 1, proper = FALSE)

tau(n)

Arguments

n

Positive integer.

k

Numeric scalar, the exponent to be used.

proper

Logical; if TRUE, n will not be considered as a divisor of itself; default: FALSE.

Details

Total sum of all integer divisors of n to the power of k, including 1 and n.

For k=0 this is the number of divisors, for k=1 it is the sum of all divisors of n.

tau is Ramanujan's tau function, here computed using Sigma(., 5) and Sigma(., 11).

A number is called refactorable, if tau(n) divides n, for example n=12 or n=18.

Value

Natural number, the number or sum of all divisors.

Note

Works well up to 10^9.

References

https://en.wikipedia.org/wiki/Divisor_function

https://en.wikipedia.org/wiki/Ramanujan_tau_function

See Also

primeFactors, divisors

Examples

1
2
3
sapply(1:16, Sigma, k = 0)
sapply(1:16, Sigma, k = 1)
sapply(1:16, Sigma, proper = TRUE)

Example output

 [1] 1 2 2 3 2 4 2 4 3 4 2 6 2 4 4 5
 [1]  1  3  4  7  6 12  8 15 13 18 12 28 14 24 24 31
 [1]  0  1  1  3  1  6  1  7  4  8  1 16  1 10  9 15

numbers documentation built on May 15, 2021, 1:08 a.m.