Question: Java program. 7. Generating prime numbers Write a program that uses the primality test derived from Fermat's Little Theorem to generate a sequence of prime

Java program.

7. Generating prime numbers Write a program that uses the primality test derived from Fermat's Little Theorem to generate a sequence of prime numbers. The program will repeat the following 16 times (and so generate 16 prime numbers):

  • In a loop:
    • Randomly generate an integer between 224 and 225
    • Check whether it's prime using the FLT test
    • Terminate the loop if a prime is found
  • Print the prime and the number of times the loop repeated before finding a prime

You will have to implement the FLT test. If you use Java as your language, only use primitive variables and values.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!