Large Prime Number Generation
- 18Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
State Fermat's Little Theorem in mathematical notation.
18 questions
- 1
State Fermat's Little Theorem in mathematical notation.
Model answer
For a prime p and integer a not divisible by p, ap−1≡1(modp).
Explanation
This is the precise statement of Fermat's Little Theorem, which is the foundation of many primality tests.
- 2
Describe the Fermat primality test for a candidate number n.
Model answer
Pick a base a with 1<a<n. Compute an−1modn. If the result is not 1, n is composite. If it is 1, n is probably prime.
Explanation
The test uses the contrapositive of Fermat's Little Theorem: if an−1≡1(modn), then n cannot be prime.
- 3
In the Fermat primality test, what are 'witnesses' and 'liars'?
Model answer
For a composite n, a base a such that an−1≡1(modn) is a witness to compositeness; a base that gives 1 is a liar that incorrectly suggests n is prime.
Explanation
Witnesses correctly identify composites; liars cause false positives.
- 4
Define Carmichael numbers and give an example.
Model answer
Carmichael numbers are composite integers n such that an−1≡1(modn) for all a coprime to n. The smallest Carmichael number is 561=3×11×17.
Explanation
Carmichael numbers fool the Fermat test for almost all bases, making the test unreliable.
- 5
Why is the Fermat primality test insufficient due to Carmichael numbers?
Model answer
Carmichael numbers satisfy an−1≡1(modn) for all bases coprime to n, so the Fermat test will incorrectly declare them prime unless the base shares a factor with n, which is extremely rare for large n.
Explanation
The existence of infinitely many Carmichael numbers (proved in 1994) means the Fermat test has a fatal flaw.
- 6
Describe the key procedural difference between Miller's test and the Fermat test.
Model answer
Instead of just computing an−1modn, Miller's test repeatedly halves the exponent, producing a sequence of exponentiations down to an odd exponent, and checks additional conditions on the sequence.
Explanation
This allows Miller's test to detect composite numbers that pass the Fermat test, including Carmichael numbers.
- 7
What are the two conditions Miller's test uses to declare a number prime?
Model answer
(1) The sequence must end with 1 (i.e., an−1≡1(modn)). (2) Whenever a 1 appears in the sequence, the preceding term must be 1 or n−1.
Explanation
Condition (2) checks for illegal square roots of 1 modulo n, which would indicate compositeness.
- 8
Explain why Miller's condition (2) about square roots of 1 is effective for primes.
Model answer
For a prime modulus p, the only square roots of 1 modulo p are 1 and p−1 (since x2≡1(modp) implies x≡±1). If a sequence term before a 1 is something else, it is a nontrivial square root of 1, which only exists if n is composite.
Explanation
This property allows Miller's test to catch composites that have nontrivial square roots of 1.
- 9
Give an example of a number that passes the Fermat test but is caught by Miller's test, and explain why.
Model answer
For n=561 (a Carmichael number) and base a=100, the Fermat test gives 100560≡1. Miller's test produces a sequence ending with 1 but with a 67 before a 1, violating condition (2) because 67 is not 1 or 560. Thus Miller's test correctly identifies 561 as composite.
Explanation
The presence of a nontrivial square root (672≡1(mod561)) reveals compositeness.
- 10
Despite improvements, Miller's test can still have liars. Provide an example.
Model answer
For n=221=13×17 and base a=174, Miller's test gives the sequence 47,220,1, satisfying both conditions, so it falsely declares 221 prime. 174 is a liar for Miller's test.
Explanation
This shows that Miller's test is not foolproof; some composite numbers still pass for certain bases.
- 11
How does the Extended Riemann Hypothesis (ERH) relate to Miller's test?
Model answer
If the ERH is true, then for every composite n, there is a witness base less than 2(lnn)2. Thus Miller's test run with all bases up to that bound would be a deterministic, correct primality test.
Explanation
The ERH provides a guaranteed small witness, making the test unconditionally correct if the hypothesis holds.
- 12
What is the Miller-Rabin primality test, and how does it differ from the original Miller test?
Model answer
Miller-Rabin is a probabilistic version that runs Miller's test with randomly chosen bases. It relies on the fact that for any composite n, at least 75% of bases are witnesses (Rabin's result). Repeating the test with multiple random bases gives high confidence.
Explanation
The test is not deterministic but is fast and practically reliable, unlike Miller's original test which required the ERH for certainty.
- 13
According to Rabin's improvement, what proportion of bases are witnesses for a composite number in the Miller-Rabin test?
Model answer
At least 75% (or 43) of bases are witnesses for any odd composite n.
Explanation
This high proportion ensures that after a few random bases, the probability of a false positive drops exponentially.
- 14
How many iterations of the Miller-Rabin test are typically sufficient for a 99.9999% confidence that a number is prime?
Model answer
With 10 random bases, the false positive probability is at most 0.2510≈9.5×10−7, giving 99.9999% confidence.
Explanation
Each iteration reduces the chance of error by a factor of at least 4, so ten iterations yield high certainty.
- 15
Describe the basic algorithm to generate a large prime number with a given number of digits.
Model answer
Pick a random number with the desired number of digits. Test whether it is prime (e.g., using Miller-Rabin). If it passes, output it; otherwise, repeat with a new random number.
Explanation
Due to the density of primes, this trial-and-error approach is efficient.
- 16
According to the Prime Number Theorem, what is the approximate probability that a random n-digit number is prime?
Model answer
The probability is roughly nln101≈2.3n1.
Explanation
For a thousand-digit number, this is about 1 in 2300, meaning on average 2300 attempts needed.
- 17
Why is the Miller-Rabin test preferred over a deterministic test like AKS for generating large primes in practice?
Model answer
Miller-Rabin is much faster, especially for large numbers, while AKS, though deterministic, runs significantly slower and is impractical for everyday use.
Explanation
Speed is critical when generating many large primes quickly, as in cryptographic key generation.
- 18
What is the AKS primality test, and why is it significant?
Model answer
The AKS test, discovered in 2002, is a deterministic primality test that runs in polynomial time. It was a major theoretical breakthrough but is slower than probabilistic tests like Miller-Rabin.
Explanation
It proves that primality testing is in P, but practical applications still rely on faster probabilistic methods.

Ask anything
We've read this whole study set, so questions about it get the best answers.