Python | sympy.multiplicity() method
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:
# import multiplicity() method from sympy from sympy import multiplicity p = 2n = 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)) |
chevron_right
filter_none
Output:
6 is the largest integer such that 2^6 divides 64.
Example #2:
# import multiplicity() method from sympy from sympy import multiplicity p = 3n = 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)) |
chevron_right
filter_none
Output:
1 is the largest integer such that 3^1 divides 111.
Recommended Posts:
- class method vs static method in Python
- Python | next() method
- Python | os.dup() method
- Python | set() method
- Python | os.closerange() method
- Python PIL | tobytes() Method
- Python | sympy.sin() method
- Python PIL | getpalette() Method
- Python | sympy.nP() method
- Python | os.close() method
- Python | sympy.nC() method
- Python | os.fstat() method
- Python | os.fchdir() method
- Python | os.chdir() method
- Python | os.dup2() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



