Hacker News new | ask | show | jobs
by gloria_mundi 668 days ago
I'm not sure I understand the prime density thing. Of the numbers up to 8258, about 12.5% are prime. Accounting for the fact that about a quarter of these primes ends in 101, i.e. cannot occur, I would expect about 10.7% = 12.5% * (3/4) / (7/8), which is fairly close to the observed 9.4%.

The 2.1% in the README seems to be the density of primes < 1000 among numbers up to 8258. That's not what was counted.

2 comments

After you read about Ramanujan...

https://web.williams.edu/Mathematics/sjmiller/public_html/ma...

To be honest, I have a degree in math, and struggle to understand the extreme difficulty in assessing the density of primes.

I haven't read all of that, but the problem at hand seems significantly less complicated.

We're mapping the numbers from 1 to 1000 to distinct numbers up to 8258, and the README claims that we should expect 2.1% of the resulting numbers to be prime. I see no reason for this claim, and as I understand it, the 2.1% comes from pi(1000) / 8258, which seems like nonsense to me.

I don’t remember the 2.1% thing, it could be an error, I don’t know.

I just remember the density of primes was higher: but your explanation accounts for that — well done — because it filters out.

That’s a good explanation! I didn’t think of that :) Thank you, makes more sense than it has some special bias.

Wait, what 2.1% are you referring to? That looks interesting.