michael85
unread,Jun 24, 2012, 4:47:36 PM6/24/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mpir-...@googlegroups.com
Hello Everyone,
For some reason, I am not able to understand why the following code prints different results:
mpz_t x, n, out;
mpz_init_set_ui(x, 2UL);
mpz_init_set_ui(n, 7UL);
mpz_init(out);
mpz_invert(out, x, n);
gmp_printf ("%Zd\n", out);//prints 4. 2 * 4 (mod 7) = 1. OK
mpz_powm_ui(out, x, -1UL, n);//prints 1. 2 * 1 (mod 7) = 2. How come?
gmp_printf ("%Zd\n", out);
mpz_clear(x);
mpz_clear(n);
mpz_clear(out);
The documentation states that negative exponents are supported by mpz_powm if base^-1 nod n exists. This behavior is the same as in GMP 4.1 on Windows. What am I missing here?
Best regards,
Mihai Todor