Python | sympy.udivisor_sigma() method
Last Updated :
17 Sep, 2019
With the help of
sympy.udivisor_sigma() method, we can calculate the
unitary divisor function for any positive integer
n.
udivisor_sigma(n, k) is equal to sum of all the
unitary divisors of
n raised to the power of
k or
sum([x**k for x in udivisors(n)]).
Syntax: udivisor_sigma(n, k)
Parameter:
n – It denotes an integer.
k – It denotes an integer(optional). Default for k is 1.
Returns: Returns the sum of all the unitary divisors of n raised to the power of k.
Example #1:
from sympy.ntheory.factor_ import udivisor_sigma
n = 12
udivisor_sigma_n = udivisor_sigma(n)
print ( "udivisor_sigma({}) = {} " . format (n, udivisor_sigma_n))
|
Output:
udivisor_sigma(12) = 20
Example #2:
from sympy.ntheory.factor_ import udivisor_sigma
n = 18
k = 2
udivisor_sigma_n = udivisor_sigma(n, k)
print ( "udivisor_sigma({}) = {} " . format (n, udivisor_sigma_n))
|
Output:
udivisor_sigma(18) = 410
Share your thoughts in the comments
Please Login to comment...