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:

    Andrews: Do you mind if I ask a question frankly? Do you love my daughter?
    Peter: Any guy that’d fall in love with your daughter ought to have his head examined.
    Andrews: Now that’s an evasion.
    Peter: She grabbed herself a perfect running mate. King Westley! The pill of the century. What she needs is a guy that’d take a sock at her once a day, whether it’s coming to her or not.
    Robert Riskin (1897–1955)

    When I go into a museum and see the mummies wrapped in their linen bandages, I see that the lives of men began to need reform as long ago as when they walked the earth. I come out into the streets, and meet men who declare that the time is near at hand for the redemption of the race. But as men lived in Thebes, so do they live in Dunstable today.
    Henry David Thoreau (1817–1862)