- p is a polynomial.
- q is a polynomial.

- When both p and q are integers, gcd(p,q) computes the greatest common divisor of these two integers, i.e. the greatest integer dividing both p and q.
- When both p and q are rational numbers, say a/b and c/d, gcd(p,q) computes the greatest common divisor of a * d and b * c, divided by the product of the denominators, b * d.
- When both p and q are constants but at least one of them is no rational number, gcd(p,q) returns 1.
- When at least one of p or q is a polynomial of degree at least 1, gcd(p,q) returns the polynomial of greatest degree dividing both p and q. The coefficient of the monomial of greatest degree of the returned polynomial is set to the greatest common divisor of the coefficients of the monomials of greatest degree of p and q.
- When at least one of p or q is a function that is no polynomial, gcd(p,q) returns 1.

77

> gcd(13, 17);

1

> gcd(-210, 462);

42

> gcd(6/7, 33/13);

3 / 91

1

4 + x * (4 + x)

> gcd(1001 * x^2, 231 * x);

x * 77

1