Make sure you place the mpz_init and mpz_clear in the right positions. If you are unsure of how these operations are supposed to be used, please see the GMP manual. -- Torbjörn