1. Home
  2. Explore
  3. Mathematics
  4. Large Prime Number Generation

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Large Prime Number Generation

  • 18Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Fermat's Little Theorem and Fermat Test

State Fermat's Little Theorem in mathematical notation.

18 questions

  1. 1

    State Fermat's Little Theorem in mathematical notation.

    Model answer

    For a prime ppp and integer aaa not divisible by ppp, ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{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. 2

    Describe the Fermat primality test for a candidate number nnn.

    Model answer

    Pick a base aaa with 1<a<n1 < a < n1<a<n. Compute an−1mod  na^{n-1} \mod nan−1modn. If the result is not 111, nnn is composite. If it is 111, nnn is probably prime.

    Explanation

    The test uses the contrapositive of Fermat's Little Theorem: if an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod{n}an−1≡1(modn), then nnn cannot be prime.

  3. 3

    In the Fermat primality test, what are 'witnesses' and 'liars'?

    Model answer

    For a composite nnn, a base aaa such that an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod{n}an−1≡1(modn) is a witness to compositeness; a base that gives 111 is a liar that incorrectly suggests nnn is prime.

    Explanation

    Witnesses correctly identify composites; liars cause false positives.

  4. 4

    Define Carmichael numbers and give an example.

    Model answer

    Carmichael numbers are composite integers nnn such that an−1≡1(modn)a^{n-1} \equiv 1 \pmod{n}an−1≡1(modn) for all aaa coprime to nnn. The smallest Carmichael number is 561=3×11×17561 = 3 \times 11 \times 17561=3×11×17.

    Explanation

    Carmichael numbers fool the Fermat test for almost all bases, making the test unreliable.

  5. 5

    Why is the Fermat primality test insufficient due to Carmichael numbers?

    Model answer

    Carmichael numbers satisfy an−1≡1(modn)a^{n-1} \equiv 1 \pmod{n}an−1≡1(modn) for all bases coprime to nnn, so the Fermat test will incorrectly declare them prime unless the base shares a factor with nnn, which is extremely rare for large nnn.

    Explanation

    The existence of infinitely many Carmichael numbers (proved in 1994) means the Fermat test has a fatal flaw.

  6. 6

    Describe the key procedural difference between Miller's test and the Fermat test.

    Model answer

    Instead of just computing an−1mod  na^{n-1} \mod nan−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. 7

    What are the two conditions Miller's test uses to declare a number prime?

    Model answer

    (1) The sequence must end with 111 (i.e., an−1≡1(modn)a^{n-1} \equiv 1 \pmod{n}an−1≡1(modn)). (2) Whenever a 111 appears in the sequence, the preceding term must be 111 or n−1n-1n−1.

    Explanation

    Condition (2) checks for illegal square roots of 111 modulo nnn, which would indicate compositeness.

  8. 8

    Explain why Miller's condition (2) about square roots of 111 is effective for primes.

    Model answer

    For a prime modulus ppp, the only square roots of 111 modulo ppp are 111 and p−1p-1p−1 (since x2≡1(modp)x^2 \equiv 1 \pmod{p}x2≡1(modp) implies x≡±1x \equiv \pm1x≡±1). If a sequence term before a 111 is something else, it is a nontrivial square root of 111, which only exists if nnn is composite.

    Explanation

    This property allows Miller's test to catch composites that have nontrivial square roots of 111.

  9. 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=561n=561n=561 (a Carmichael number) and base a=100a=100a=100, the Fermat test gives 100560≡1100^{560} \equiv 1100560≡1. Miller's test produces a sequence ending with 111 but with a 676767 before a 111, violating condition (2) because 676767 is not 111 or 560560560. Thus Miller's test correctly identifies 561561561 as composite.

    Explanation

    The presence of a nontrivial square root (672≡1(mod561)67^2 \equiv 1 \pmod{561}672≡1(mod561)) reveals compositeness.

  10. 10

    Despite improvements, Miller's test can still have liars. Provide an example.

    Model answer

    For n=221=13×17n=221 = 13 \times 17n=221=13×17 and base a=174a=174a=174, Miller's test gives the sequence 47,220,147, 220, 147,220,1, satisfying both conditions, so it falsely declares 221221221 prime. 174174174 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. 11

    How does the Extended Riemann Hypothesis (ERH) relate to Miller's test?

    Model answer

    If the ERH is true, then for every composite nnn, there is a witness base less than 2(ln⁡n)22(\ln n)^22(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. 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 nnn, at least 75%75\%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. 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%75\%75% (or 34\frac{3}{4}43​) of bases are witnesses for any odd composite nnn.

    Explanation

    This high proportion ensures that after a few random bases, the probability of a false positive drops exponentially.

  14. 14

    How many iterations of the Miller-Rabin test are typically sufficient for a 99.9999%99.9999\%99.9999% confidence that a number is prime?

    Model answer

    With 101010 random bases, the false positive probability is at most 0.2510≈9.5×10−70.25^{10} \approx 9.5 \times 10^{-7}0.2510≈9.5×10−7, giving 99.9999%99.9999\%99.9999% confidence.

    Explanation

    Each iteration reduces the chance of error by a factor of at least 444, so ten iterations yield high certainty.

  15. 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. 16

    According to the Prime Number Theorem, what is the approximate probability that a random nnn-digit number is prime?

    Model answer

    The probability is roughly 1nln⁡10≈12.3n\frac{1}{n \ln 10} \approx \frac{1}{2.3n}nln101​≈2.3n1​.

    Explanation

    For a thousand-digit number, this is about 111 in 230023002300, meaning on average 230023002300 attempts needed.

  17. 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. 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.

1 of 18
Question 1 of 18

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent