Fermat factorization implmentation