Python | sympy.gcd() method
The function
gcd() provides the direct way to compute Greatest Common Divisor for polynomials.That is, for polynomials f and g, it computes GCD.
Syntax: sympy.gcd(f, g) Return: GCD of given polynomials
Example #1:
# import sympy from sympy import * f = (12 * x + 12)*x g = 32 * x**2 # Using sympy.gcd() method gfg = gcd(f, g) print(gfg) |
chevron_right
filter_none
Output:
4*x
Example #2:
# import sympy from sympy import * f = 3 * x**2 / 2g = 9 * x / 4 # Using sympy.gcd() method gfg = gcd(f, g) print(gfg) |
chevron_right
filter_none
Output:
x
Recommended Posts:
- class method vs static method in Python
- Python | next() method
- Python | set() method
- Python | os.dup() method
- Python | sympy.Pow() method
- Python | os.WIFCONTINUED() method
- Python PIL | blend() method
- Python | Decimal max() method
- Python Dictionary | pop() method
- Python PIL | Image.new() method
- Python | range() method
- Python | os.sysconf() method
- Python | Tensorflow exp() method
- Python | os.confstr() method
- Python | os.fchmod() 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.


