factorize f(x) and g(x) .
the product of common factors will be the gcd.
So we are dealing in modulo 3. The first thing I would do is simplify : 7= 1 (mod 3) and 6= 0 (mod 3). So which we could also write as x(x+2)(x+1). To factor , look at the general . We need to find a and b such that a+ b= 2 (mod 3) and ab= 1 (mod 3). a= b= 1 should be obvious.