GCD / polynomial GCD online calculator: Calculate the greatest common divisor of integers and polynomials

The gcd command produces the GCD of integers and polynomials. If you write gcd 12 16 in the form above, the calculator will output 2 as follows.

GCD 12 16

GCD is the greatest common divisor and the GCD of 12 and 16 is 4. 1, 2, 4 are the divisors of them and 4 is the greatest one. The calculator can't take decimals such as 3.9 because it's not an integer. You can find the GCD of three or more integers in this online calculator.

gcd 12 16 24

The calculator shows 4. All numbers need separated by comma or space. So both gcd 12, 16 and gcd 12 16 are valid.

Polynomial GCD

We can find the GCD polynomials of two or more polynomials whose coefficients are all integers. X, Y are polynomials and can be factored like this.

X = ABC, Y=ABD

A, B, C, D are polynomials that can't be factored. Then A and B are the common polynomial divisors so we can call AB the "polynomial GCD of X and Y". Let's write the below code in the form and check the output.

gcd x**2-1, x**3-1

The calculator shows x-1.

GCD of polynomials

In fact, x-1 can divide both polynomials. Note that the calculator can't recognize the implicit multiplication like 2x, 3x and caret symbol ^. Multiplication symbol is one asterisk and power symbol is double asterisks. To calculate a polynomial GCD, all polynomials you input need separated by comma. The below won't work because the arguments are separated by space.

gcd x**2-1 x**3-1

Auto simplification

The next example works because cos(0) is simplified to 1 before calculating the GCD.

gcd x-1, x-cos(0)

The output is x-1.

Arithmetic

Calculator