New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Much faster solution #2
Conversation
Simple comparisons:
And it's not a probabilistic test. |
This is great, thank you~! I did see your original comment in #1 – I just wanted to mess around and implement AKS since I didn't see an implementation anywhere. PS, I know it's slow 😄 Is this a known algorithm / theorem? Or it a brute force method you've come up with? I pushed a change to this PR with a refactored version. It's 50B smaller (gzip) and is actually significantly faster, too. It's the same logic, but you were checking against (and reassigning) the
Here are the benchmarks of your original PR against the refactor. I've also included Theorem, if that's okay! The number sets are taken from the tests.
|
Great! TheoremJS should be slower as it uses the It's an algorithm I came with, but it's based on Eratosthenes' sieve. |
Yeah, I saw that. Totally makes sense. Thanks! The name was escaping me, I was thinking it began with an S___ 🙃 |
Hey @arguiot, I switched approaches again~! If you check out the latest README, you can find benchmarks of the new approach. |
@lukeed great 👍. I saw that in |
Oh shoot, sorry! I was distracted. 🙈 |
Proposing an incredibly fast solution for checking if a number is prime or not.
Currently working fine until
Number.MAX_SAFE_INTEGER
.This was inspired by the code I have written for https://github.com/arguiot/TheoremJS. I already told you about this in #1