How to get decimal form of largest known prime?

Tim Peters tim.peters at gmail.com
Tue Jun 15 05:36:06 CEST 2004


[David M. Cooke]
> ...
> Interesting, because with gmpy (on a 32-bit AMD64 machine running Linux):
>
> >>> import gmpy
> >>> x = gmpy.mpz(2)**24036583-1
>
> is almost instantaneous, whereas the straight Python takes a second.

The version of GMP in use is doubtless the reason.  I suspect the
precompiled GMP that ships with mxNumber is getting long in the tooth.

> But then with gmpy I get
> >>> print x
> Segmentation fault
>
> so I can't win here :-)

That's OK, you don't lose, either <wink>.  Under mxNumber, I tried
stuffing the big prime into a Rational, then displaying it with the
Rational.format(base) method (which some GMP msgs suggested used a
faster base-conversion algorithm for huge numbers), and used
base=1000.  That segfaulted on Windows.

In return for Python's comparative sloth at times, I think I can count
the number of crashes pinned on its bigint implementation over the
last decade on 0 fingers, and the number of bugs on one hand.  It's
one of purest demonstrations of the love affair between simplicity and
reliability I've seen in industrial life.




More information about the Python-list mailing list