Solution (source code)

= Solution

If a prime divided every coefficient of $fg$, reducing modulo that prime would make the product of the two nonzero reduced primitive <polynomials> zero in a domain, impossible. Thus a product of primitive <polynomials> is primitive. Factoring the contents from arbitrary $f,g$ then gives
$$
c(fg)=u,c(f)c(g)
$$
for a unit $u$.