Big integer Runtime Library: GMP

Source: Internet
Author: User
Tags gmp

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.