mpz_powm_ui () for 5.1.2
shen lixing
shenlixing at hotmail.com
Wed Mar 8 01:17:05 UTC 2017
Hi,
developer!
I installed MinGW, then 'mingw-get install mingw32-gmp' , got the gmp 5.1.2 properly.
mpz_powm_ui () give a wrong calculation as below (compared and confirmed by Python):
// 2^(c-1) = 1 mod c^2, c = ?
#include <stdio.h>
#include <time.h>
#include <gmp.h>
int main()
{ printf("hello, world! \n");
unsigned long long c = 10307e7 - 1; // change c,start point
printf("c reach %llu \n",c);
mpz_t a,b,d;
mpz_inits(a,b,d,NULL);
mpz_set_ui(a,2);
for (; ;c += 2)
{ if (c % 100000000 == 1)
{ printf("c reach %llu, %llu \n",c,(unsigned long long)time(NULL));
}
mpz_set_ui(b,c);
mpz_mul_ui(b,b,c);
mpz_powm_ui(d,a,c-1,b );
if (mpz_cmp_ui(d,1) == 0) // c = 1093,3511 are solutions. why 103079216179 ?
{ printf("found %llu \n",c);
return 0;
}
}
}
I saw a bug report for the mpz_powm_ui () in 5.1.1. from https://gmplib.org.
Regards,
shen lixing
2017/3/8
GNU Multiple Precision Arithmetic Library - gmplib<https://gmplib.org/>
gmplib.org
What is GMP? GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers.
More information about the gmp-bugs
mailing list