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:

    It was far in the sameness of the wood;
    I was running with joy on the Demon’s trail,
    Though I knew what I hunted was no true god.
    Robert Frost (1874–1963)

    Few can be induced to labor exclusively for posterity; and none will do it enthusiastically. Posterity has done nothing for us; and theorize on it as we may, practically we shall do very little for it, unless we are made to think we are at the same time doing something for ourselves.
    Abraham Lincoln (1809–1865)