Highest Common Factor using Prime Factorization