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:

    “Would you—be good enough—” Alice panted out, after running a little further, “to stop a minute—just to get—one’s breath again?”
    “I’m good enough,” the King said, “only I’m not strong enough. You see, a minute goes by so fearfully quick. You might as well try to stop a Bandersnatch!”
    Lewis Carroll [Charles Lutwidge Dodgson] (1832–1898)

    If the Almighty had intended for you to be rich, he’d have taken care of that a long time ago. The idea of you being rich, that’s plain blasphemy.
    Robert Rossen (1908–1966)