439
you are viewing a single comment's thread
view the rest of the comments
[-] Hexarei@programming.dev 6 points 1 year ago

As an update to my earlier nerd-sniped-ness:

I found a list of prime numbers, which states that the 50,000,000th prime number is 982,451,653, which means 5.08930896% of the numbers up to 982,451,653 are prime. That's unfortunate, as it means the accuracy is actually lower than the original post we go further - down from 95.121% accuracy to 94.921%. Bummer!

Out of curiosity, I then whipped up a quick program in rust that starts from those numbers, crunching forward through the primes while prime_count as f32 / total_count as f32 > 0.05, using 16 CPU cores to divide-and-conquer and check whether a number is prime. There's probably a better way to do that, but meh. Such a check will essentially only get me back above 95% though, and based on the rate of change, I suspect it would take an exponentially higher amount of time than whatever it takes to get to 99.5%.

In the time it's taken me to write this, it's calculated just over 330,000 more primes, reaching ~0.050874 hit rate for primes.

This has led me down a small rabbit hole, in which it turns out there are plenty of folks who have approached the topic of "what percentage of numbers are prime?" - and the answer is essentially "it will eventually round to 0%". Because of you, I remain curious to know when that crosses the threshold of 99.5% though - and I'll at least leave it running for the next day or two to see how close it gets.

Unfortunately though, at the rate my PC can calculate, I don't think I'm personally gonna be hitting an answer to this any time soon. If I ever do manage to figure it out, I'll be sure to update... because hell, why not.

I've also considered trying to find bigger lists of primes, but meh. I've already spent an hour on this that I intended to spend playing D&D so ... meh. =]

[-] xthexder@programming.dev 2 points 1 year ago

We got nerd sniped at almost the exact same time, but approached this in very different ways. I applaud your practical approach, but based on what I calculated, you should stop now. It will never reach 99.999%

[-] Hexarei@programming.dev 1 points 1 year ago

Whew. I'm only going for 99.5%, which according to your other comment is doable!... But impractical

[-] xthexder@programming.dev 1 points 1 year ago* (last edited 1 year ago)

99.5% would still be e^200 numbers checked (7x10^86). According to the Quora link in my other comment, we've only calculated primes in sequence up to 4x10^18 as of 7 years ago. 95% is very doable though.

Edited to correct first N primes vs primes up to N.

[-] Hexarei@programming.dev 2 points 1 year ago

Incredible amounts of numbers. Crazy.

this post was submitted on 03 Jul 2023
439 points (97.8% liked)

Programmer Humor

19503 readers
760 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS