748
o(1) statistical prime approximation
(lemmy.blahaj.zone)
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.
If you scaled it based on the size of the integer you could get that up to 99.9% test accuracy. Like if it's less than 10 give it 50% odds of returning false, if it's under 50 give it 10% odds, otherwise return false.
That would make it less accurate. It's much more likely to return true on not a prime than a prime
Code proof or it didn't happen.
Extra credit for doing it in Ruby
Makes me wonder where the actual break even would be. Like how long dies making one random number take versus sins lookups. Fuck it, do it in parallel. Fastest wins.
Now you're thinking with ~~portals~~ primes!