850
submitted 4 days ago* (last edited 4 days ago) by not_IO@lemmy.blahaj.zone to c/programmer_humor@programming.dev
you are viewing a single comment's thread
view the rest of the comments
[-] Semi_Hemi_Demigod@lemmy.world 14 points 3 days ago* (last edited 3 days ago)

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.

[-] LodeMike@lemmy.today 4 points 3 days ago

That would make it less accurate. It's much more likely to return true on not a prime than a prime

[-] themusicman@lemmy.world 2 points 2 days ago

Correct. Not are why people are upvoting. If 10% of numbers are prime in a range, and you always guess false, you get 90% right. If you randomly guess true 10% of the time, you get ~80% right.

[-] LodeMike@lemmy.today 1 points 2 days ago

More random means more towards 50% correctness.

[-] ptu@sopuli.xyz 3 points 2 days ago

And 2,3,5,7 are primes of the first numbers, making always false 60% correct and random chance 50%

[-] Semi_Hemi_Demigod@lemmy.world 2 points 3 days ago

Code proof or it didn't happen.

Extra credit for doing it in Ruby

[-] Jayjader@jlai.lu 4 points 3 days ago

Now you're thinking with ~~portals~~ primes!

[-] JackbyDev@programming.dev 1 points 3 days ago* (last edited 2 days ago)

Makes me wonder where the actual break even would be. Like how long does making one random number take versus sins lookups. Fuck it, do it in parallel. Fastest wins.

this post was submitted on 22 Feb 2026
850 points (99.1% liked)

Programmer Humor

30013 readers
2057 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 2 years ago
MODERATORS