Fermat Primality Test - Algorithm and Running Time

Algorithm and Running Time

The algorithm can be written as follows:

Inputs: n: a value to test for primality; k: a parameter that determines the number of times to test for primality Output: composite if n is composite, otherwise probably prime repeat k times: pick a randomly in the range if, then return composite return probably prime

Using fast algorithms for modular exponentiation, the running time of this algorithm is O(k × log2n × log log n × log log log n), where k is the number of times we test a random a, and n is the value we want to test for primality.

Read more about this topic:  Fermat Primality Test

Famous quotes containing the words running and/or time:

    “What was any art but an effort to make a sheath, a mould in which to imprison for a moment the shining, elusive element which is life itself—life hurrying past us and running away, too strong to stop, too sweet to lose?”
    —Willa Cather (1873–1947)

    “It is time to provide a smashing answer for those cynical men who say that a democracy cannot be honest, cannot be efficient.... We have in the darkest moments of our national trials retained our faith in our own ability to master our own destiny.”
    —Franklin D. Roosevelt (1882–1945)