Wednesday, October 8, 2025
HomeLanguagesPython | sympy.multiplicity() method

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 = 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))


Output:

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

Example #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))


Output:

1 is the largest integer such that 3^1 divides 111.
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11875 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS