Open In App

Python | sympy.lcm() method

Improve
Improve
Like Article
Like
Save
Share
Report

The function lcm() provides the direct way to compute Least Common Multiple for polynomials.That is, for polynomials f and g, it computes LCM.

Syntax: sympy.lcm(f, g)

Return: LCM of given polynomials

Example #1:




# import sympy  
from sympy import * f = x * y**2 + x**2 * y
g = x**2 * y**2
  
# Using sympy.lcm() method 
gfg = lcm(f, g)
  
print(gfg)


Output:

x**3*y**2 + x**2*y**3

Example #2:




# import sympy  
from sympy import * f = x * y / 2 + y**2
g = 3 * x + 6 * y
  
# Using sympy.lcm() method 
gfg = lcm(f, g)
  
print(gfg)


Output:

x*y + 2*y**2

Last Updated : 17 Sep, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads