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

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

What does Fermat's Little Theorem state for a prime ppp and integer aaa not divisible by ppp?

28 questions

  1. 1

    What does Fermat's Little Theorem state for a prime ppp and integer aaa not divisible by ppp?

    1. A

      ap≡1(modp)a^p \equiv 1 \pmod{p}ap≡1(modp)

    2. B

      ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}ap−1≡1(modp)

    3. C

      ap−1≡0(modp)a^{p-1} \equiv 0 \pmod{p}ap−1≡0(modp)

    4. D

      ap≡0(modp)a^p \equiv 0 \pmod{p}ap≡0(modp)

    Correct answer
    B

    ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}ap−1≡1(modp)

    Explanation

    Fermat's Little Theorem states that if ppp is prime and aaa is not divisible by ppp, then ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}ap−1≡1(modp).

  2. 2

    In the congruence ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}ap−1≡1(modp), what does the term "mod" refer to?

    1. A

      The base of the exponentiation

    2. B

      The remainder when dividing ap−1a^{p-1}ap−1 by ppp

    3. C

      The result of multiplying aaa by ppp

    4. D

      The exponent used in the expression

    Correct answer
    B

    The remainder when dividing ap−1a^{p-1}ap−1 by ppp

    Explanation

    "Mod" indicates modular arithmetic, where numbers are considered congruent to their remainder upon division by the modulus ppp.

  3. 3

    According to the Fermat Primality Test, if for some aaa we have an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod{n}an−1≡1(modn), what can we conclude?

    1. A

      nnn might be prime or composite

    2. B

      nnn is definitely prime

    3. C

      nnn is definitely composite

    4. D

      aaa is a liar

    Correct answer
    C

    nnn is definitely composite

    Explanation

    If an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod{n}an−1≡1(modn), then nnn cannot be prime, because Fermat's Little Theorem requires the congruence to hold for primes. Thus nnn is composite.

  4. 4

    In the Fermat Primality Test, what is a "witness"?

    1. A

      A base aaa such that an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod{n}an−1≡1(modn) for composite nnn

    2. B

      A base aaa such that an−1≡1(modn)a^{n-1} \equiv 1 \pmod{n}an−1≡1(modn) for composite nnn

    3. C

      A base aaa that is coprime to nnn

    4. D

      A base aaa such that an−1≡1(modn)a^{n-1} \equiv 1 \pmod{n}an−1≡1(modn) for prime nnn

    Correct answer
    A

    A base aaa such that an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod{n}an−1≡1(modn) for composite nnn

    Explanation

    A witness is a base that reveals a composite number by violating Fermat's congruence. If an−1≢1(modn)a^{n-1} \not\equiv 1 \pmod{n}an−1≡1(modn), then aaa is a witness to nnn's compositeness.

  5. 5

    When testing n=51n=51n=51 with base a=2a=2a=2, the Fermat test yields 250≡4(mod51)2^{50} \equiv 4 \pmod{51}250≡4(mod51). What does this indicate?

    1. A

      51 is prime

    2. B

      The test is inconclusive

    3. C

      51 is composite

    4. D

      2 is a liar

    Correct answer
    C

    51 is composite

    Explanation

    Since 250≢1(mod51)2^{50} \not\equiv 1 \pmod{51}250≡1(mod51), Fermat's test correctly identifies 51 as composite (it factors as 3×173 \times 173×17).

  6. 6

    What is a Carmichael number?

    1. A

      A prime number that fails the Fermat test for some bases

    2. B

      A prime number that passes the Fermat test for all bases

    3. C

      A composite number that passes the Fermat test for all bases coprime to it

    4. D

      A composite number that fails the Fermat test for all bases

    Correct answer
    C

    A composite number that passes the Fermat test for all bases coprime to it

    Explanation

    Carmichael numbers are composite numbers that have the property that an−1≡1(modn)a^{n-1} \equiv 1 \pmod{n}an−1≡1(modn) for every aaa coprime to nnn, making them frequent false positives in the Fermat test.

  7. 7

    Which of the following is the first Carmichael number?

    1. A

      51

    2. B

      41

    3. C

      561

    4. D

      221

    Correct answer
    C

    561

    Explanation

    561 is the smallest Carmichael number; it equals 3×11×173 \times 11 \times 173×11×17 and passes the Fermat test for any base coprime to it.

  8. 8

    In the Fermat test, why are Carmichael numbers problematic?

    1. A

      They are prime but the test indicates composite

    2. B

      They are prime but fail the test for most bases

    3. C

      They are composite but often pass the test for bases that do not share a factor with them

    4. D

      They are composite and always fail the test

    Correct answer
    C

    They are composite but often pass the test for bases that do not share a factor with them

    Explanation

    Carmichael numbers consistently pass the Fermat test for bases that are coprime to them, leading to false primality declarations. Only bases sharing a factor with the number can expose them.

  9. 9

    Who proved that there are infinitely many Carmichael numbers?

    1. A

      Michael Rabin

    2. B

      Gary Miller

    3. C

      Fermat

    4. D

      Alford, Granville, and Pomerance

    Correct answer
    D

    Alford, Granville, and Pomerance

    Explanation

    In 1994, Red Alford, Andrew Granville, and Carl Pomerance proved that infinitely many Carmichael numbers exist, confirming the fatal flaw in the Fermat test.

  10. 10

    In the content, why did base 424242 correctly identify 561561561 as composite in Fermat's test?

    1. A

      Because 42 and 561 share a factor of 3

    2. B

      Because 42 is even

    3. C

      Because 561 is a Carmichael number

    4. D

      Because 42 is greater than the square root of 561

    Correct answer
    A

    Because 42 and 561 share a factor of 3

    Explanation

    42 and 561 share the factor 3, so the Fermat congruence fails, making 42 a witness to compositeness.

  11. 11

    What is the key innovation of Miller's test over Fermat's test?

    1. A

      It breaks the exponentiation into a sequence of smaller exponentiations by repeatedly dividing the exponent by 2

    2. B

      It checks if nnn is even

    3. C

      It uses a probabilistic approach

    4. D

      It uses a different base

    Correct answer
    A

    It breaks the exponentiation into a sequence of smaller exponentiations by repeatedly dividing the exponent by 2

    Explanation

    Miller's test computes a sequence of exponentiations a(n−1)/2ka^{(n-1)/2^k}a(n−1)/2k for k=0,1,…k=0,1,\ldotsk=0,1,…, which provides additional checks for nontrivial square roots of 1.

  12. 12

    In Miller's test, after computing an−1 mod na^{n-1} \bmod nan−1modn, what is the next step?

    1. A

      Subtract 1 from the result

    2. B

      Check if the result is 1

    3. C

      Divide the exponent by 2 repeatedly until odd, computing the modular exponentiation at each step

    4. D

      Multiply the result by aaa

    Correct answer
    C

    Divide the exponent by 2 repeatedly until odd, computing the modular exponentiation at each step

    Explanation

    Miller's test repeatedly halves the exponent (while it is even) and computes the modular exponentiation at each step, generating a sequence of values.

  13. 13

    Miller's test has two conditions. What are they?

    1. A

      The final number must equal the base

    2. B

      The final number in the sequence must be 1, and any time there is a 1, the number before it must be 1 or n−1n-1n−1

    3. C

      The sequence must start with 1 and end with n−1n-1n−1

    4. D

      The sequence must contain only 1s and n−1n-1n−1s

    Correct answer
    B

    The final number in the sequence must be 1, and any time there is a 1, the number before it must be 1 or n−1n-1n−1

    Explanation

    Condition 1: the last element equals 1. Condition 2: whenever a 1 appears, the preceding element must be either 1 or n−1n-1n−1 (which is −1 mod n-1\bmod n−1modn). This checks for illegal square roots of 1.

  14. 14

    Why is the second condition of Miller's test valid for prime numbers?

    1. A

      Because for a prime modulus, the only square roots of 1 are 1 and −1-1−1 (mod ppp)

    2. B

      Because Fermat's Little Theorem guarantees it

    3. C

      Because for a composite modulus, square roots of 1 are always 1 and n−1n-1n−1

    4. D

      Because for a prime modulus, the only cube roots of 1 are 1 and p−1p-1p−1

    Correct answer
    A

    Because for a prime modulus, the only square roots of 1 are 1 and −1-1−1 (mod ppp)

    Explanation

    When the modulus is prime, the equation x2≡1(modp)x^2 \equiv 1 \pmod{p}x2≡1(modp) has exactly two solutions: 111 and p−1p-1p−1 (which is −1-1−1). Any other square root of 1 would imply compositeness.

  15. 15

    For n=561n=561n=561 and a=100a=100a=100, Miller's test finds a sequence ending with 1, but the number before the final 1 is 67. What does this indicate?

    1. A

      100 is a liar

    2. B

      561 is prime

    3. C

      The test is inconclusive

    4. D

      561 is composite

    Correct answer
    D

    561 is composite

    Explanation

    67 is a square root of 1 modulo 561 that is neither 1 nor 560, violating condition 2. Thus the test correctly identifies 561 as composite.

  16. 16

    Despite improvements, Miller's test can still be fooled. Which of the following is an example?

    1. A

      n=51n=51n=51, a=2a=2a=2

    2. B

      n=221n=221n=221, a=174a=174a=174

    3. C

      n=561n=561n=561, a=100a=100a=100

    4. D

      n=41n=41n=41, a=8a=8a=8

    Correct answer
    B

    n=221n=221n=221, a=174a=174a=174

    Explanation

    For n=221=13×17n=221=13\times17n=221=13×17, base 174 satisfies both conditions of Miller's test, making 174 a liar. 221 is composite but Miller's test declares it prime with this base.

  17. 17

    What is the AKS primality test?

    1. A

      A test that only works for Carmichael numbers

    2. B

      A probabilistic test that is faster than Miller-Rabin

    3. C

      A deterministic test that is always correct but slower in practice

    4. D

      A test based solely on Fermat's Little Theorem

    Correct answer
    C

    A deterministic test that is always correct but slower in practice

    Explanation

    The AKS test, discovered in 2002, is the first deterministic primality test that runs in polynomial time, but it is impractical for large numbers due to its slowness compared to Miller-Rabin.

  18. 18

    Why is the AKS primality test not commonly used for generating large primes in practice?

    1. A

      It runs much slower than Miller-Rabin

    2. B

      It requires the Extended Riemann Hypothesis to be true

    3. C

      It is probabilistic and can be wrong

    4. D

      It only works for numbers less than 10610^6106

    Correct answer
    A

    It runs much slower than Miller-Rabin

    Explanation

    Although deterministic, AKS is significantly slower than the probabilistic Miller-Rabin test, making it unsuitable for generating large primes where speed is essential.

  19. 19

    In the Miller-Rabin test, what proportion of bases are witnesses for an odd composite number, according to Rabin's result?

    1. A

      At least 90%

    2. B

      At least 75%

    3. C

      Exactly 100%

    4. D

      At least 50%

    Correct answer
    B

    At least 75%

    Explanation

    Rabin proved that at least 75% of bases (in the range 2≤a≤n−22 \leq a \leq n-22≤a≤n−2) are witnesses for any odd composite nnn, improving on Miller's 50% lower bound.

  20. 20

    What is the main difference between Miller's original test and the Miller-Rabin test?

    1. A

      The Miller-Rabin test is deterministic while Miller's is probabilistic

    2. B

      The Miller-Rabin test uses a different condition for primality

    3. C

      The Miller-Rabin test only works for even numbers

    4. D

      The Miller-Rabin test uses random bases and is probabilistic, while Miller's was deterministic if the Extended Riemann Hypothesis is true

    Correct answer
    D

    The Miller-Rabin test uses random bases and is probabilistic, while Miller's was deterministic if the Extended Riemann Hypothesis is true

    Explanation

    Miller's original test becomes deterministic if the Extended Riemann Hypothesis holds, but it requires checking all bases up to a bound. Rabin made the test probabilistic by using random bases, which is practical and efficient.

  21. 21

    How does the probability of false positive change when running the Miller-Rabin test with more random bases?

    1. A

      It remains constant

    2. B

      It increases

    3. C

      It decreases exponentially

    4. D

      It decreases linearly

    Correct answer
    C

    It decreases exponentially

    Explanation

    Because each independent random base has at most a 25% chance of lying (since at least 75% are witnesses), the false positive probability decreases exponentially with the number of iterations.

  22. 22

    With 10 iterations of the Miller-Rabin test (each with a random base), what is the approximate maximum false positive probability?

    1. A

      1 in 100

    2. B

      1 in 1,000

    3. C

      1 in 1,000,000

    4. D

      1 in 10

    Correct answer
    C

    1 in 1,000,000

    Explanation

    With at least 75% witnesses per base, the probability that a composite number passes all 10 tests is at most (1/4)10≈10−6(1/4)^{10} \approx 10^{-6}(1/4)10≈10−6, i.e., about 1 in a million.

  23. 23

    What role does the Extended Riemann Hypothesis play in Miller's original algorithm?

    1. A

      It is unrelated to primality testing

    2. B

      It proves that there are infinitely many Carmichael numbers

    3. C

      It guarantees that Miller's test is always correct with enough bases

    4. D

      It shows that the proportion of witnesses is at least 50%

    Correct answer
    C

    It guarantees that Miller's test is always correct with enough bases

    Explanation

    If the Extended Riemann Hypothesis is true, Miller proved that for every composite nnn, there exists a witness less than 2(ln⁡n)22(\ln n)^22(lnn)2. Thus checking all bases up to that bound yields a deterministic test.

  24. 24

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

    1. A

      1 in 2300

    2. B

      1 in 2.3

    3. C

      1 in 230

    4. D

      1 in 23,000

    Correct answer
    A

    1 in 2300

    Explanation

    The probability is about 1/(ln⁡(10)⋅n)=1/(2.3026⋅1000)≈1/23031/(\ln(10)\cdot n) = 1/(2.3026 \cdot 1000) \approx 1/23031/(ln(10)⋅n)=1/(2.3026⋅1000)≈1/2303, so roughly 1 in 2300.

  25. 25

    What is the basic strategy used by computers to generate large prime numbers?

    1. A

      Use the Euclidean algorithm

    2. B

      Multiply two small primes to get a large prime

    3. C

      Pick a random number, test it for primality, and repeat until a prime is found

    4. D

      Use a formula that always produces primes

    Correct answer
    C

    Pick a random number, test it for primality, and repeat until a prime is found

    Explanation

    The strategy is to randomly select candidate numbers of the desired length and test them for primality (using Miller-Rabin) until one passes; this works because primes are sufficiently dense.

  26. 26

    For a random nnn-digit number, the probability of being prime is approximately:

    1. A

      1n\frac{1}{n}n1​

    2. B

      1n2\frac{1}{n^2}n21​

    3. C

      1ln⁡(10)⋅n\frac{1}{\ln(10)\cdot n}ln(10)⋅n1​

    4. D

      12n\frac{1}{2^n}2n1​

    Correct answer
    C

    1ln⁡(10)⋅n\frac{1}{\ln(10)\cdot n}ln(10)⋅n1​

    Explanation

    The Prime Number Theorem implies that the density of primes near a number xxx is 1/ln⁡x1/\ln x1/lnx. For an nnn-digit number, xxx is about 10n−110^{n-1}10n−1, so ln⁡x≈ln⁡(10)⋅n\ln x \approx \ln(10)\cdot nlnx≈ln(10)⋅n, giving probability 1/(ln⁡(10)⋅n)1/(\ln(10)\cdot n)1/(ln(10)⋅n).

  27. 27

    According to the Prime Number Theorem, the chance that a random 10-digit number is prime is closest to:

    1. A

      1 in 23

    2. B

      1 in 2300

    3. C

      1 in 2.3

    4. D

      1 in 230

    Correct answer
    A

    1 in 23

    Explanation

    For a 10-digit number, n=10n=10n=10, so probability ≈1/(2.3026⋅10)=1/23.026\approx 1/(2.3026 \cdot 10) = 1/23.026≈1/(2.3026⋅10)=1/23.026, or about 1 in 23.

  28. 28

    How many random thousand-digit numbers would need to be tested on average to find a prime, according to the Prime Number Theorem?

    1. A

      About 2300

    2. B

      About 230

    3. C

      About 23,000

    4. D

      About 2.3 million

    Correct answer
    A

    About 2300

    Explanation

    The probability is about 1 in 2300, so on average one would need to test roughly 2300 candidates to find a prime.

Question 1 of 28
Question 1 of 28

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent