- p is a constant or a polynomial.
- q is a constant or 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 non-negative 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 both p and q are polynomials with at least one being non-constant, gcd(p,q) returns the polynomial of greatest degree dividing both p and q, and whose leading coefficient is the greatest common divisor of the leading coefficients of p and q.
- Similarly to the cases documented for div and mod, gcd may fail to return the unique polynomial of largest degree dividing both p and q in cases when certain coefficients of either p or q are constant expressions for which the tool is unable to determine whether they are zero or not. These cases typically involve polynomials whose leading coefficient is zero but the tool is unable to detect this fact.
- 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