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#.