How to get decimal form of largest known prime?
dyoo at hkn.eecs.berkeley.edu
Fri Jun 11 00:29:48 CEST 2004
Claudio Grondi <claudio.grondi at freenet.de> wrote:
: According to latest news the largest known prime is:
: 2**24036583 - 1
: Do someone of you know how long would it take on
: a 2.8 GHz Pentium 4 machine to write a _decimal_ form
: (hexadecimal form can be written in less than one second)
: of this prime to a file and what should be the Python code
: to use for it?
Let's see... how many digits would it be?
>>> def digits(n):
... return int(math.log(n) / math.log(10)) + 1
>>> x = 2**2436583 - 1
Ok, that doesn't sound too bad at all. It's about 750,000 digits long.
It's actually not difficult to get the last decimal digit of this
>>> x % 10
It's also not too difficult to get the second to last digit of this
>>> (x / 10) % 10
At least we can figure out that the number ends with a '07'. If we
continue this way, we can quickly get the other digits.
Hope this helps!
More information about the Python-list