Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

isPrime(p) is polynomial relative to the number of digits of p, but not in any useful way- takes way too long practically speaking. But that's only if you want a definite solution.

If you're willing to do a probabilistic test, you can use algorithms like Miller-Rabin- the more time you use it with random inputs the more sure you are that the number is prime. And it's relatively easy to implement- check Wikipedia for the pseudocode.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: