A small C program to print the biggest prime number

Here it is (448 bytes):

int m=1811939329,N=1,t[1<<26]={2},a,*p,i,e=73421233,s,c,U=1;g(d,h){for(i=s;i<1<<

This program computes 274207281-1, which was the biggest known prime number in 2016 (about 23 million digits !). For more information about how it was found and who found it, look at the GIMPS Project .

I compiled it successfully with gcc with Linux. In order to compile it, your C compiler must support the 64 bit long long type.

In order to have a small and yet asymptotically efficient code, I decided to do the computation of 2N-1 directly in base 10. The power involves repeated squarings and multiplications by two. The squarings are implemented by doing fast convolutions using a Number Theoretic Transform.

A previous version of this program to compute 26972593-1 won the International Obfuscated C Code Contest of Year 2000.

Thanks to Marco Cecchi who suggested some syntactic changes to save a few characters.

This program is Freeware.

Fabrice Bellard - http://bellard.org/
last update: Sep 26, 2016