Back around the year 1991 I read about the RSA algorithm and thought it would be interesting to play with the maths behind the
public key encryption process. That lead to the need for a decent stock of prime numbers, and in those days long, long before
the WWW, the easiest way was to write a programme to generate them.
So I put together, originally, a GW basic bit of code that
generated prime numbers - but VERY slowly! Over time that software was refined, converted to a compiled language and turned
into a form that could be run any time the PC was turned on, starting where it left off last time and building up the list.
Over the years I sporadically ran the prog when I thought about it.
The bit of software just sat on, and got copied to, every PC I acquired since those early days. Every so often I'd rediscover and
run the softwafe, sometimes for many hours on end in the background. Back in 1991 it typically generated at less than ten new prime
numbers per second on the 20 - 50MHz DOS machines of that era. Of late, on a 2GHz PC it was generating at up to 380 per second -
and that was with VERY much larger values than the initial slow starter worked on. All the calculations were done in 16 bit maths
using the original DOS based software so could only ever be run on an XP machine as Win 7 won't run 16 bit DOS applications.
On 14 May 2015 it reached a milestone. That bit of ancient software met the largest number it can handle - the software uses
signed 32-bit integers so that is 2^31-1, which just happens to be a Mersene prime of about 2.1 billion.
So without a software rewrite that's it. And these days, if you want to play with RSA there are far better ways of getting some
very large primes indeed. Very much bigger than any here.
A quick look on the web showed that no one else seemed to have downloadable files of all the primes up to a value anywhere like
as high as this, although a plethora of sites would generate large primes, or random ones, or lists of all of them up to smaller values.
So I thought my list might as well be made available to all. If you can find a use for all 105097566 of the prime numbers up to
2147483647 you're welcome to download it from PRIMES.ZIP
But beware, the compressed file is 147 Meg in size, so make sure you have a good internet connection!
Once unzipped, the resulting 400 Meg file PRIMES.DAT has a simple structure. The format is 32 bit binary, LSByte first in
standard Windows format. Read 4 bytes at a time into 32 bit integers.
The first value in the record is the number of primes stored 105097566, the next is the first prime number 2, then they simply run
from 3, 5, 7 , 11 etc. up to 2^31-1
If you can use this list, please let me know what you're doing with it - just for interest. These days the numbers in there are far
too small be be of any use in cracking RSA or anything along those lines other than just simple demonstration of the algorithms -
and you don't need a list of all the primes for that anyway.
And finally, a couple of progs FACTORS.ZIP
written in 16 bit powerbasic (source code included for info) to give the prime factors of a number up
to [a bit less than] 2^64, and to generate random prime numbers up to that limit. As they are in 16 bit code, you'll have to run them
on an operating system of Win XP or earlier, or use a DOS emulator. Or recompile into 32 bit code
Of course, since Euclid proved nearly 2500 years ago that there are an infinite number of primes, this list
clearly comprises exactly 0% of them.
Enjoy !
Back to Index