📜  Python| sympy.udivisor_sigma() 方法

📅  最后修改于: 2022-05-13 01:55:19.904000             🧑  作者: Mango

Python| sympy.udivisor_sigma() 方法

借助sympy.udivisor_sigma()方法,我们可以计算酉除数函数\sigma_k^*(n)对于任何正整数nudivisor_sigma(n, k)等于n的所有酉除数之和的k次幂或sum([x**k for x in udivisors(n)])

示例 #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

输出:

udivisor_sigma(12) =  20

示例 #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)) 

输出:

udivisor_sigma(18) =  410