Hello,

Recently I've been looking at HashSet and HashTable implementations in
Mono, and I've found some code to generate prime numbers as a helper
for the algorithms, it uses a pre-calculated array of primes. This
array skips a few primes, while I think that for the use of this
primes that are close in the code may be somehow hit the performance,
I don't understand in general what was the criteria of skipping
primes.

The array contains the following numbers:

11, 19, 37, 73, 109, 163, 251, 367, 557, 823, 1237, 1861, 2777, 4177,
6247, 9371, 14057, 21089, 31627, 47431, 71143, 106721, 160073, 240101,
360163

and some times, also:

540217, 810343, 1215497, 1823231, 2734867, 4102283, 6153409, 9230113,
13845163

I've found that this same array also exists other projects under
Apache software fundation, among other places.

My question is if this some arcane knowledge of why skip certain
primes forever lost in the ancient library of alexandria, preserved
for the even more arcane habit of code reutilization known as copy-
paste, or does anybody know how did they come to this list.

In abstract: does somebody know why this primes and no others?

I hope I'm able to understand it when I see the explanation, I bet my
brain is not as good to abstract the pattern...

By the way, the code for prime generation is long tested (of course,
it's in a lot of open implementation) and has been long overcame. If
you search a bit on this group the chances are of finding a little
riddle* for a fast prime generation algarothm.... so, this has nothing
to do with the algorithm, just the pre-calculated array... I just
don't want to think that skipping this primes is a defect.

*It was one year ago (Challenge: Generate Prime Numbers). Salutes to
Ram and CK, and let's take the chance and salute Cerberus too.

I repeate the question in case you missed it: does somebody know why
this primes and no others?

Theraot

Reply via email to