Ah yes, my favorite recurring lemmy post! It even has the same incorrect test output.
Last time I saw this I did a few calculations based on comments people made: https://l.sw0.com/comment/32691 (when are we going to be able to link to comments across instances?)
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%
In response to the question of how long it would take to round up to 100%:
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.
But you can use randomised test-cases. Better yet, you can randomise values in test-cases once and throw away the ones you don’t like and get arbitrarily close to 100% with a reasonable amount of tests
Ah yes, my favorite recurring lemmy post! It even has the same incorrect test output.
Last time I saw this I did a few calculations based on comments people made:
https://l.sw0.com/comment/32691 (when are we going to be able to link to comments across instances?)
But you can use randomised test-cases. Better yet, you can randomise values in test-cases once
and throw away the ones you don’t likeand get arbitrarily close to 100% with a reasonable amount of tests