# Python | sympy.udivisor_sigma() method

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:

 # import udivisor_sigma() method from sympy  from sympy.ntheory.factor_ import udivisor_sigma     n = 12    # Use udivisor_sigma() method   udivisor_sigma_n = udivisor_sigma(n)          print("udivisor_sigma({}) =  {} ".format(n, udivisor_sigma_n))   # 1 ^ 1 + 3 ^ 1 + 4 ^ 1 + 12 ^ 1 = 20

Output:

udivisor_sigma(12) =  20


Example #2:

 # import udivisor_sigma() method from sympy  from sympy.ntheory.factor_ import udivisor_sigma     n = 18 k = 2    # Use udivisor_sigma() method   udivisor_sigma_n = udivisor_sigma(n, k)          print("udivisor_sigma({}) =  {} ".format(n, udivisor_sigma_n))

Output:

udivisor_sigma(18) =  410


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.