LLMpediaThe first transparent, open encyclopedia generated by LLMs

Fermat primality test

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Expansion Funnel Raw 72 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted72
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
Fermat primality test
NameFermat primality test
TypeProbabilistic primality test
InventorPierre de Fermat
Year17th century
Inputinteger n > 1
Output"probable prime" or composite

Fermat primality test

The Fermat primality test is a probabilistic algorithm for assessing whether an integer is likely prime, originating from the work of Pierre de Fermat, developed alongside contributions from Leonhard Euler, Adrien-Marie Legendre, and later refinements by Sophie Germain and Évariste Galois. It relies on a special case of Fermat's Little Theorem as applied in contexts related to number theory, modular arithmetic, and the theory of congruence (number theory). The test forms a foundational element in computational projects influenced by institutions such as Bell Labs, IBM, and research efforts at Massachusetts Institute of Technology, Princeton University, and University of Cambridge.

Introduction

Fermat's Little Theorem asserts that for a prime p and integer a with 1 < a < p, a^(p−1) ≡ 1 (mod p), a result central to the test and linked historically to correspondence between Pierre de Fermat and Marin Mersenne. The Fermat primality test selects random bases a and checks the congruence a^(n−1) ≡ 1 (mod n); failure implies compositeness, while success yields a "probable prime" verdict. The method influenced subsequent algorithms from researchers at Bell Labs and in projects like the Great Internet Mersenne Prime Search and complements deterministic methods such as the AKS primality test and classical tests used by Jean-Pierre Serre and Carl Friedrich Gauss in foundational studies.

Theoretical background

The test is grounded in Fermat's Little Theorem and properties of the multiplicative group (Z/nZ)^× studied in group theory and by mathematicians including Évariste Galois and Niels Henrik Abel. For prime modulus p the group is cyclic of order p−1, a fact exploited in proofs by Leonhard Euler and later in formulations used by Arthur Cayley and William Rowan Hamilton. When n is composite, the congruence can hold for some bases a, yielding pseudoprimes; such behavior connects to work by Robert Carmichael, Alfredo Cataldi, and investigations published in journals associated with Royal Society and American Mathematical Society. The notion of multiplicative order, Euler's totient function φ(n) studied by Leonhard Euler, and character theory developed by Émile Borel inform bounds on false-positive rates and link to criteria explored by Dirichlet, Srinivasa Ramanujan, and G.H. Hardy.

Algorithm and implementation

A basic implementation picks random integers a in [2, n−2] and computes a^(n−1) mod n via fast modular exponentiation using algorithms credited to Donald Knuth and implementations used at Microsoft Research and Google. Practical code often uses exponentiation by squaring refined by techniques from John von Neumann and optimized in libraries maintained by GNU Project and OpenSSL contributors. Hardware acceleration leveraging instruction sets designed by Intel and ARM Holdings is common in production-grade primality tools, and distributed computations coordinate through platforms like Berkeley Open Infrastructure for Network Computing influenced by University of California, Berkeley projects.

Accuracy, limitations, and Carmichael numbers

The Fermat test can falsely classify composite n as probable prime for bases a called Fermat liars; these anomalies motivated the discovery of Carmichael number by Robert Carmichael. Carmichael numbers such as 561 were characterized using methods influenced by Sophie Germain and later structural theorems by Alfred North Whitehead and Paul Erdős. For composite n that are not Carmichael, at least half of possible bases detect compositeness, a bound proved using group actions studied by Évariste Galois and Camille Jordan. Counterexamples and constructed sequences were analyzed by Korselt and compiled in databases maintained by institutions like National Institute of Standards and Technology and literature from American Mathematical Monthly.

Complexity and performance

Runtime depends on modular exponentiation complexity, typically O(k·log^3 n) bit operations for k random bases under classical algorithms analyzed in texts by Ronald Rivest, Adi Shamir, and Leonard Adleman. Improvements using fast multiplication algorithms attributed to André Schönhage and Volker Strassen reduce costs; asymptotic bounds leverage results from Peter Shor in quantum contexts and deterministic alternatives such as the AKS primality test by Manindra Agrawal, Neeraj Kayal, and Nitin Saxena. Empirical performance comparisons published in proceedings of International Congress of Mathematicians often favor probabilistic approaches in applied settings at organizations including European Organization for Nuclear Research and NASA.

Practical applications and variants

In practice the Fermat test appears in cryptographic key generation frameworks designed by Ronald Rivest, Adi Shamir, and Leonard Adleman for RSA (cryptosystem), and in primality screening for protocols standardized by International Organization for Standardization and Internet Engineering Task Force. Variants include the Solovay–Strassen primality test developed by Robert Solovay and Volker Strassen, and the Miller–Rabin primality test refined by Gary L. Miller and Michael O. Rabin, which reduce false positives using strong probable prime criteria influenced by research at Bell Labs and Cryptography Research, Inc.. Large-scale prime searches by Great Internet Mersenne Prime Search and record discoveries announced by Guinness World Records leverage these methods alongside deterministic checks performed by teams at University of Central Missouri and national laboratories.

Category:Primality tests