samedi 26 juin 2021

GMP generating random number in C

I wanted to generate random number called r in loop using gmp library. Then I add this random number r to the variable l. I prefer range of random r between 1 and 1000000.

int main()
{

do
{

   mpz_add_ui(l,l,r)

}while(1)

   return 0;

}

I think I should use function mpz_urandomb() but I don't know how to implement it.

Thank you for your help.




Aucun commentaire:

Enregistrer un commentaire