The Biggest Prime
February 8, 2013
This is a simple program:
> (with-output-to-file "bigprime.txt"
(display (- (expt 2 57885161) 1))))
However, when I ran that program, the machine thrashed for a while, and after about a minute, crashed. So I wrote this program using C/GMP, which can be compiled with the command
gcc bigprime.c -lgmp -o bigprime:
/* bigprime.c -- save the digits of 2^57885161-1 to a file */
fp = fopen("bigprime.txt","w");
mpz_ui_pow_ui(p, 2, 57885161);
mpz_sub_ui(p, p, 1);
gmp_fprintf(fp, "%Zd", p);
The program ran successfully, creating the
bigprime.txt file in about a minute. You can see the program at http://programmingpraxis.codepad.org/xbg11nxk.
Pages: 1 2