📜  Python| sympy.primeomega() 方法

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

Python| sympy.primeomega() 方法

sympy.primeomega()方法的帮助下,我们可以计算给定正整数的素数计数重数。例如, primeomega(12) = 3 ,因为12 = 2 2 * 3 1 。因此,质因数的个数 = 质因数的重数之和, 2 + 1 = 3。

示例 #1:

# import primeomega() method from sympy
from sympy.ntheory.factor_ import primeomega
  
n = 24
  
# Use primeomega() method 
primeomega_n = primeomega(n) 
      
print(" Number of prime factors of {} = {} ".format(n, primeomega_n))

输出:

Number of prime factors of 24 = 4 

示例 #2:

# import primeomega() method from sympy
from sympy.ntheory.factor_ import primeomega
  
n = 120
  
# Use primeomega() method 
primeomega_n = primeomega(n) 
      
print(" Number of prime factors of {} = {} ".format(n, primeomega_n))

输出:

Number of prime factors of 120 = 5