Python | sympy.multiplicity() method
Last Updated :
05 Sep, 2019
With the help of sympy.multiplicity() method, we can find the greatest integer m such that p raised to the power of m divides n, where p and n are parameters of the method
Syntax:
multiplicity(p, n)
Parameter:
p – It denotes an integer.
n – It denotes an integer.
Returns:
Returns the greatest integer m such that p^m divides n.
Example #1:
from sympy import multiplicity
p = 2
n = 64
multi_p_n = multiplicity(p, n)
print ( "{} is the largest integer such that {}^{} divides {}." .
format (multi_p_n, p, multi_p_n, n))
|
Output:
6 is the largest integer such that 2^6 divides 64.
Example #2:
from sympy import multiplicity
p = 3
n = 111
multi_p_n = multiplicity(p, n)
print ( "{} is the largest integer such that {}^{} divides {}." .
format (multi_p_n, p, multi_p_n, n))
|
Output:
1 is the largest integer such that 3^1 divides 111.
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...