quadratic sieve implementation