Arthur Besse@lemmy.ml to Programmer Humor@lemmy.mlEnglish · edit-28 hours agoIncredible stochastic algorithm, gets more reliable the larger your input, incredibly fast, trivial to implement and deterministic on its inputsimagemessage-square20fedilinkarrow-up1258arrow-down14file-text
arrow-up1254arrow-down1imageIncredible stochastic algorithm, gets more reliable the larger your input, incredibly fast, trivial to implement and deterministic on its inputsArthur Besse@lemmy.ml to Programmer Humor@lemmy.mlEnglish · edit-28 hours agomessage-square20fedilinkfile-text
cross-posted from: https://lemmy.blahaj.zone/post/38950495 https://cosocial.ca/@mhoye/116111505546606451
minus-square/home/pineapplelover@lemmy.dbzer0.comlinkfedilinkarrow-up10arrow-down1·5 hours agoI’m confused, shouldn’t this be printing false no matter what the input is?
minus-squareCarl [he/him]@hexbear.netlinkfedilinkEnglisharrow-up12·edit-25 hours agothat’s the joke, since most numbers aren’t prime, this function is technically highly accurate despite being completely useless.
minus-squareanton@lemmy.blahaj.zonelinkfedilinkarrow-up3·3 hours 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++; } } //...
I’m confused, shouldn’t this be printing false no matter what the input is?
that’s the joke, since most numbers aren’t prime, this function is technically highly accurate despite being completely useless.
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++; } } //...Removed by mod
Removed by mod