Arthur Besse@lemmy.ml to Programmer Humor@lemmy.mlEnglish · edit-25 hours agoIncredible stochastic algorithm, gets more reliable the larger your input, incredibly fast, trivial to implement and deterministic on its inputslemmy.mlimagemessage-square18fedilinkarrow-up1231arrow-down13file-text
arrow-up1228arrow-down1imageIncredible stochastic algorithm, gets more reliable the larger your input, incredibly fast, trivial to implement and deterministic on its inputslemmy.mlArthur Besse@lemmy.ml to Programmer Humor@lemmy.mlEnglish · edit-25 hours agomessage-square18fedilinkfile-text
cross-posted from: https://lemmy.blahaj.zone/post/38950495 https://cosocial.ca/@mhoye/116111505546606451
minus-square/home/pineapplelover@lemmy.dbzer0.comlinkfedilinkarrow-up7arrow-down1·2 hours agoI’m confused, shouldn’t this be printing false no matter what the input is?
minus-squareanton@lemmy.blahaj.zonelinkfedilinkarrow-up1·19 minutes agoThe test suite probably looks something like this: int tests_passed=0; int tests_failed=0; for(int i=0;i<100000;i++){ printf("test no. %d: ", i); if(is_prime(i)==actually_is_prime(i)){ printf("passed\n"); tests_passed++; }else{ printf("failed\n"); tests_failed++; } } //...
minus-squareCarl [he/him]@hexbear.netlinkfedilinkEnglisharrow-up7·edit-22 hours agothat’s the joke, since most numbers aren’t prime, this function is technically highly accurate despite being completely useless.
I’m confused, shouldn’t this be printing false no matter what the input is?
The test suite probably looks something like this:
int tests_passed=0; int tests_failed=0; for(int i=0;i<100000;i++){ printf("test no. %d: ", i); if(is_prime(i)==actually_is_prime(i)){ printf("passed\n"); tests_passed++; }else{ printf("failed\n"); tests_failed++; } } //...that’s the joke, since most numbers aren’t prime, this function is technically highly accurate despite being completely useless.
Removed by mod
Removed by mod