The 41th Mersenne Prime

Eric W. Weisstein and Ed Pegg, Jr.

In May of 2004, Josh Findley's computer discovered the 41st known Mersenne prime.  Evaluate the cell below to caculate its value.

mersenne41 = 2^24036583  -  1;

Evaluate the cell below to calculate the decimal digits of the prime.

digits = IntegerDigits[mersenne41]; // Timing

Evaluate the cell below to compute the number of decimal digits in the prime.

Length[digits]

Evaluate the cell below to see the first and last few digits

ToString[FromDigits[Take[digits, 20]]] <> "⋯" <> 
      ToString[FromDigits[Take[digits, -20]]]

Evaluate the following to compute the number of times each decimal digit appears.

counts = Length /@ Split[Sort[digits]]

Evaluate the following to generate a nicely formatted table showing the distribution of digits.

DisplayForm[
      GridBox[
MapIndexed[{#2[[1]] - 1, #1} &, 
          counts], GridFrame -> True, RowLines -> True, 
        ColumnLines -> True]]

As can be seen, 3 is the rarest digit, and 9 is the most common.  Evaluate the cell below to show a ranked list of digits by frequency, with the rarest digit appearing first.

Ordering[counts] - 1

There are 7,235,733 digits.  Evaluate the cell below to verify that the above counts sum to the total number of digits.

Plus @@ counts

Evaluate the cell below to see the full prime

mersenne41

The original algorithm for finding large Mersenne primes was developed in Mathematica by Richard Crandall.  At www.perfsci.com, the product "PrimeKit" is available, which is a precise, one-to-one collection of Notebooks for the algorithms in the Crandall/Pomerance "Prime numbers" book. The IBDWT algorithm is in there, as are all other book algorithms.  The Prime Numbers book is at http://library.wolfram.com/infocenter/Books/953/.