ghp4 from cs240, prime factorization added