What's the best data structure (in java) for the task of loading 51 million primes and then iterating over them?
I need to know, for example, the primes that are between 1000000000 and that same number minus 100000.
A binary search isn't going to be wonderful for this data, since the first half of the primes are going to be closer to each other than the last half of them.
You might be able to improve on your search by knowing how many primes there are under x. Maybe skew the cut by using the approximation mentioned in the link.
My first try would be this. I'd have two arrays.
I'd get a rough position with array 2 before doing anything with array 1.