Teen Programmers Unite  


Return to forum top

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:


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.

You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.