I like it. Rather than being 100% correct and tending towards a better runtime, it has a perfect runtime and tends towards more correctness as N increases.
Seems familiar. Something that gets progressively more correct and harder to identify faults as the amount of data increases, but with no intelligence underneath.
Superb. And this checks out, as I've found that the more you test your code the better it gets. This is why I run my unit tests 1000 times after each change instead of once, it will be more when I get a new computer.
No, worse. Your true negative non-primes (26 of those between 1 and 100) now become false positive and only 24 primes switch from false negative to true positive, so you end up with 73%.
Excellent suggestion! However, returning true for all odd numbers would introduce false positives for composite numbers such as 9, 15, 21, and 25. ⚠️
My implementation instead uses a bounded conditional to identify the first three odd primes, achieving a measurable improvement in classification accuracy while preserving O(1) time complexity. 😎
This represents a 4% relative improvement over the original implementation on a sample of 100 integers. 🎓🏆
#include chatgpt.h
bool func(int n){
bool ans = chatgpt.prompt("tell me wether %d is prime or not. return true or false, no explanations.", n);
return ans;
}
1.8k
u/StrangelyBrown 7d ago
I like it. Rather than being 100% correct and tending towards a better runtime, it has a perfect runtime and tends towards more correctness as N increases.
524
u/Llonkrednaxela 7d ago
I love this, an actual programming joke in this sub.
278
u/TerroDucky 7d ago
If you did this in rust it would be like O(0,5)
47
u/stbrumme 7d ago
that code correctly catches edge cases such as n=3.7 and n="prime"
106
u/GegeAkutamiOfficial 7d ago
127
u/LoreBadTime 7d ago edited 4d ago
[This text has been randomized: melon]
tea daylight sand middle twilight camera
64
u/neomasterc 7d ago •
Seems familiar. Something that gets progressively more correct and harder to identify faults as the amount of data increases, but with no intelligence underneath.
28
u/Old_Information6270 7d ago
I need some time to get it. Too late
28
u/gnutrino 6d ago
Also O(1) and more accurate. Also non-deterministic so you can sell it to management as AI driven.
26
u/brute_force 7d ago
could have it check if it is a specific image of the drink prime, otherwise return false.
7
u/zx48 7d ago
Superb. And this checks out, as I've found that the more you test your code the better it gets. This is why I run my unit tests 1000 times after each change instead of once, it will be more when I get a new computer.
5
u/NomaTyx 7d ago
this joke is really old but somehow never gets less funny
5
u/netherlandsftw 7d ago
As n → ∞, correctness → 100%. Truly asymptotically correct
11
u/likegamertr 7d ago
Now just return true if it’s odd and you have so much better accuracy!
3
u/wolftick 7d ago
Now proven to be reliable.
5
u/Stummi 7d ago
This is why you should know the difference between sensitivity and specificity
2
u/DiscipleOfYeshua 6d ago
It’s like my buddy who gave up on training his whacko dog and instead started “commanding” him to do whatever he was already doing.
Dog is barking: “Bark, Oz! Good boy.”
Dog is sleeping: “Sleep, Oz! Good boy.”
2
u/scheimong 6d ago
Ah yes the classic stopped clock.
2
u/PM-ME-UR-DARKNESS 6d ago
Best one I ever used is
2
u/coloredgreyscale 5d ago
return true for odd numbers <= 23 to improve the accuracy.
then again, the performance cost of the reduced isOdd implementation may not be worth it.
1
u/FinalNandBit 7d ago
This is an amazing algorithm that grows in accuracy as n grows!
1
u/abednego-gomes 7d ago
is_mersenne_prime would be even more accurate.
1
u/ligma_then_sugma 6d ago
just gets better and better
amazing
1
u/SuitableDragonfly 6d ago
For future reference, a post title friendly way to say this is just "constant time".
1
u/Multifruit256 6d ago
Actually, this is 100% accuracy with any sample size if the random numbers you pick are from 0/1 to Inf
1
u/rainwulf 6d ago
Fuzzy logic.
1
u/dubchuck 4d ago
The best part is that, according to the Prime Number Theorem, its asymptotic accuracy actually converges to 100%.
1
u/thetrailofthedead 4d ago
Just hardcode every prime into a hash table < the parameter data type range
1
u/usr011235 3d ago
actually it is technically appliable when n is large enough
0
u/0xt0bi03 6d ago