📜  Python| sympy.divisor_count() 方法

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

Python| sympy.divisor_count() 方法

sympy.divisor_count()方法的帮助下,我们可以计算给定整数的除数。

示例 #1:

# import divisor_count() method from sympy
from sympy import divisor_count
  
n = 84
  
# Use divisor_count() method 
divisor_count_n = divisor_count(n) 
      
print("The number of divisors of {} : {}".format(n, divisor_count_n))

输出:

The number of divisors of 84 : 12

示例 #2:

# import divisor_count() method from sympy
from sympy import divisor_count
  
n = 12
  
# Use divisor_count() method 
divisor_count_n = divisor_count(n, modulus = 2) 
      
print("The number of divisors of {} : {}".format(n, divisor_count_n))

输出:

The number of divisors of 12 : 4