📜  Python| sympy.primenu() 方法

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

Python| sympy.primenu() 方法

借助sympy.primenu()方法,我们可以计算给定正整数的不同素因子的数量。

示例 #1:

# import primenu() method from sympy
from sympy.ntheory.factor_ import primenu
  
n = 24
  
# Use primenu() method 
primenu_n = primenu(n) 
      
print("Number of distinct prime factors of {} = {} ".format(n, primenu_n)) # 2 and 3

输出:

Number of distinct prime factors of 24 = 2  

示例 #2:

# import primenu() method from sympy
from sympy.ntheory.factor_ import primenu
  
n = 2 * 3*7 * 11 * 13
  
# Use primenu() method 
primenu_n = primenu(n) 
      
print("Number of distinct prime factors of {} = {} ".format(n, primenu_n))  

输出:

Number of distinct prime factors of 6006 = 5