Sumanta Sarkar <sumanta_r at isical.ac.in> writes: I have found a bug. The function "unsigned long int mpz_mod_ui (mpz_t r, mpz_t n, unsigned long int d)" is not returning proper value when r is negative. Your report leaves something to be desired. http://swox.com/gmp/manual/Reporting-Bugs.html -- Torbjörn