Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deterministically checking whether a large number is prime or composite?

I'm searching for an algorithm to primality test large (like 10200) numbers. Are there any good algorithms?

Ideally, I'd prefer an algorithm that isn't probabalistic.

Note: Numbers have over 50 and less then 200 digits.

like image 739
gaussblurinc Avatar asked Feb 05 '12 19:02

gaussblurinc


1 Answers

If you're looking for a non-probabalistic test, you may want to check out the AKS primality testing algorithm, which runs in roughly O(log6 n) time. For the number of digits you have, this is probably feasible.

That said, probabalistic primality tests are extremely good and many have exponentially small error rates. I would suggest using one of those unless there's a good reason not to.

EDIT: I just found this page containing several C++ implementations of AKS. I have no idea whether they work correctly or not, but they might be a good starting point.

Hope this helps!

like image 111
templatetypedef Avatar answered Sep 19 '22 10:09

templatetypedef