View Single Post
Old 2020-02-08, 02:59   #36
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

2×7×419 Posts
Default

There is a glorious algorithm proudly posted on Stack Overflow:
Code:
isPrime(testNum)
{
    if ( testNum <= 1 )
        return false;
    for ( primeFactor = 2; primeFactor < testNum; primeFactor++ )
        if ( isPrime(primeFactor) )
            if ( testNum % primeFactor == 0 )
                return false;
    return true;
}
which could be adapted for this purpose. It would take over 10^978123027341497027 recursive calls to isPrime() to determine the primality of 2^67-1 with this algorithm.
CRGreathouse is offline   Reply With Quote