Here I go re-inventing the wheel again. Wheel factorization that is.

First a shout goes out to Nathan who correctly identified my prime number routine as being a re-hash of wheel factorization.  It seems that it's a bigger wheel than most people are using, though.  Big enough wheel that perhaps this could become the monster truck of prime number calculation.  I don't yet know if it will be slower or faster than other implementations, but nonetheless it has been fun to experiment with.  Maybe with some luck it could help someone find a prime with 10 million digits, and win the $100,000 prize from EFF.  The folks hunting Marsenne primes are pretty close to a winning solution, having already found a prime with 9.8 million digits.

Just how big a wheel is now being used, you may ask?  Well, last week the prime number finder routine used just a quarter billion entries, and stored a million primes.  But I took a few moments this evening to upgrade it to use a custom class to store bitwise information instead of using the .NET BitArray.  Since BitArray uses an int for its indexer it's limited to 2 billion bits.  The new routine uses a long for the indexer so it can allocate much more memory.  It also has a custom technique to record the primes, throwing out lots of duplicated info.  In just over 2.5 gigs of RAM it can now cover 647 trillion entries!  In that space it can store the first 36 billion primes.  It will take awhile for all those to get calculated out though.  After I get all the pieces working this approach should make searching for primes about 7000 times faster than more conventional methods.

If this routine were ever to do truly serious prime number searches then for speed I'd probably have to port it to C++, but for the time being it's been interesting to see how far I could push C#.


Feedback

# re: Here I go re-inventing the wheel again. Wheel factorization that is.

How do you store 10 millin digits such that you can do a calculation on it? What software are the guys using/writing to do these sorts of calculations? 7/15/2007 4:59 AM | Guy Ellis

# re: Here I go re-inventing the wheel again. Wheel factorization that is.

I've got a C# routine I wrote, but in the C++ world most folks use PARI, which is nicely optimized.

http://pari.math.u-bordeaux.fr/ 7/15/2007 11:49 PM | Lorin Thwaits

# re: Here I go re-inventing the wheel again. Wheel factorization that is.

I may have misunderstood. When you wrote 10 million digits, did you mean an integer up to 10 million or 10 million decimals digits side by side. I had assumed the latter. e.g.: 28673662...98866. Replace the elipses with 9,999,987 more digits. 7/19/2007 3:12 AM | Guy Ellis

# re: Here I go re-inventing the wheel again. Wheel factorization that is.

Guy -- you had assumed correctly -- a number that is ten million digits long. If written out in its entirety, it would be twice as long as the Holy Bible. (Counting both the old and new testaments.)

The optimization I'm trying is designed to weed out 6999 out of every 7000 numbers as being definitely not prime, speeding up the process of finding that needle in a haystack of a 10 million digit long prime. 7/19/2007 3:36 PM | Lorin Thwaits

Post a comment





 

Please add 3 and 3 and type the answer here:

News


Welcome to my blog.
Here's what we've got on the menu today:

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Syndication: