📜  Python| sympy.multiplicity() 方法

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

Python| sympy.multiplicity() 方法

sympy.multiplicity()方法的帮助下,我们可以找到最大的整数m使得pm次方除以n ,其中pn是该方法的参数

示例 #1:

# import multiplicity() method from sympy
from sympy import multiplicity
  
p = 2
n = 64
  
# Use multiplicity() method 
multi_p_n = multiplicity(p, n) 
      
print("{} is the largest integer such that {}^{} divides {}.".
      format(multi_p_n, p, multi_p_n, n))

输出:

6 is the largest integer such that 2^6 divides 64.

示例 #2:

# import multiplicity() method from sympy
from sympy import multiplicity
  
p = 3
n = 111
  
# Use multiplicity() method 
multi_p_n = multiplicity(p, n) 
      
print("{} is the largest integer such that {}^{} divides {}.".
      format(multi_p_n, p, multi_p_n, n))

输出:

1 is the largest integer such that 3^1 divides 111.