Chat on IRC |
Help! Test if a number is prime in C++
Posted by Psion [send private reply] at August 07, 2002, 09:37:29 PM
Check Slashdot today for a link to a paper with the current best known primality testing algorithm in terms of theoretical speed without relying on randomness! You can also look for the Miller-Rabin algorithm on the web.
Posted by brian0918 [send private reply] at August 07, 2002, 10:22:04 PM
I see the algorithm, but how on earth do I put that into a form of C++ ???
For everyone else, you can find this algorithm here, on page 4: http://www.cse.iitk.ac.in/primality.pdf How could this be turned into C++ code?
Posted by Psion [send private reply] at August 08, 2002, 08:16:31 AM
I didn't really peruse that one myself, but Miller-Rabin is pretty straightforward if you have routines for fast modular arithmetic on "bignum"'s available.
Register as a new user | |||||