The gcd command computes the greatest common divisor of A and B, which can be integers or polynomials. An optional third argument P specifies the modulus for polynomial computations modulo a prime.
# integers gcd(10,15); 5 # polynomials gcd(x^2-1,x^3-1); x-1 # polynomials mod p gcd(x^2-1,x^3-1,11); x+10