LARGE numbers

Mike Meyer mwm at mired.org
Fri Nov 11 03:08:07 EST 2005


"Tuvas" <tuvas21 at gmail.com> writes:

> I've been thinking about writing a program to generate the world's
> largest prime numbers, just for the fun of it. This would require being
> able to hold an 8000000 digit number into memory (25 megabits, or a
> little over 3 megs of memory for just one variable...) I would also
> need several smaller variables. This came about as I optimised a prime
> number generator more and more, until I came with the idea to try to
> find the largest ever, using python. Any ideas? I'll probably try to
> run this on a mainframe eventually, although they might not like it
> very much... I'll run it on my home computer to first test it. Anyways,
> let me know if there's a way to make python support numbers so high.

Python already supports numbers that large:

>>> math.log(10 ** 8000000)
18420680.743952367
>>> 

However, you probably want to look into something like gmpy, as you'll
get better performance out of it.

    <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list