HCF by prime factorization