change factorization to gcd