this post was submitted on 03 Jul 2023
507 points (98.1% liked)

Programmer Humor

19594 readers
399 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] Xylight@programming.dev 10 points 1 year ago (8 children)

How long would this have to run for it to round up to 100%?

[–] xthexder@programming.dev 37 points 1 year ago (1 children)

A few calculations:

  • There are 9592 prime numbers less than 100,000. Assuming the test suite only tests numbers 1-99999, the accuracy should actually be only 90.408%, not 95.121%
  • The 1 trillionth prime number is 29,996,224,275,833. This would mean even the first 29 trillion primes would only get you to 96.667% accuracy.
  • The density of primes can be approximated using the Prime Number Theorem: 1/ln(x). Solving 99.9995 = 100 - 100 / ln(x) for x gives e^200000 or 7.88 × 10^86858. In other words, the universe will end before any current computer could check that many numbers.
[–] Xylight@programming.dev 2 points 1 year ago

they did the math!

load more comments (6 replies)