Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
I would definitely recommend using the GMP library here.
I have dev-cpp and this is how I used it.
1) Download the devpack zip file provided by theBeast32
2) Unzip it.
3) Copy it into the directory C:\Dev-Cpp\Packages
4) Run it.
5) Open up Dev-cpp and create a console windows project.
6) Now the important bit.
Go to Tools > compiler options >
and paste into the box 'Add the following commands when calling the compiler':
-lgmpxx -lgmp
Make sure to tick the box is ticked.test code
#include <iostream>
#include "gmp.h"
#include "gmpxx.h"
using namespace std;
mpz_class factorial ( mpz_class, mpz_class );
int main()
{
mpz_class a, b, c;
a = "125";
b = "107";
c = factorial ( a, b );
cout << c;
getchar();
return 0;
}
mpz_class factorial ( mpz_class a, mpz_class b )
{
mpz_class c = a;
for ( mpz_class i = b; i > 1; i-- )
{
c = c * a;
}
return c;
}
Now just hit the compile and run button.output
23408381773460991635779247069293382849575116693970916581685777269301916383369998
24743317548769632316721526895315710009819587668709957465602306134616903764463545
37270758622261454531755971164574958720550057478249073028564453125
And you can even use the modulus operator as normal which is %
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439