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:

    “I abide by a rule concerning reviews: I will never ask, neither in writing nor in person, that a word be put in about my book.... One feels cleaner this way. When someone asks that his book be reviewed he risks running up against a vulgarity offensive to authorial sensibilities.”
    —Anton Pavlovich Chekhov (1860–1904)

    “We should spend less time ranking children and more time helping them to identify their natural competencies and gifts and cultivate these. There are hundreds and hundreds of ways to succeed and many, many different abilities that will help you get there.”
    —Howard Gardner (20th century)