Niels, > Wouldn't that patch call mpz_legendre (a, p) with p not prime? Which is > invalid, but kind-of works *because* mpz_legendre is an alias for > mpz_jacobi. good point. Do you want a new patch which ensures p is an odd positive prime? Paul