GMP is short for GNU multiple-precision. It is a free Big integer computing library and exposes all source code. its official website seems to be gnu mp home page. however, the above GMP libraries are only provided for Linux.
I uploaded a Windows pre-compiled version to csdn, which can be statically linked (under the lib directory) or dynamically linked (under the dll Directory)
Http://download.csdn.net/source/270555
After extracting any version to a directory, add the corresponding header file directory and library file directory to the standard header file and library file search path of VC. for example, in vc6.0, you can use the menu tools/options ..., then select the label directories and add the path to include files and library files respectively. (If dynamic links are used, it is best to copy the dynamic link library to the Standard execution directory, such as C:/Windows/system32)
Below is a document of the GMP library I found through Google:
GMP Manual
In use, you must add
# Include <GMP. h>
Add GMP. lib to the link option in project seetings (or directly insert GMP. Lib into the project ).
The following code finds out some large prime numbers:
# Include <GMP. h>
# Include <stdio. h>
Int
Main (void)
{
Int I;
Mpz_init (m );
For (I = 1; I <1000; I ++ ){
Char * P = Buf;
Int J;
For (j = 0; j <I-1; j ++ ){
P [J] = '9 ';
}
P [J] = '7'; P [J + 1] = '/0 ';
Mpz_set_str (M, Buf, 10 );
If (mpz_probab_prime_p (M, 10 )){
Printf ("Possible Prime: 10 ^ % D-3/N", I );
}
}
Mpz_clear (m );
Return 0;
}
In addition, some programs in my blog use GMP, such as computing n! A non-zero 18-digit number at the end