Test the conjecture that there is at least one prime between each pair of consecutive square numbers.
Question:
Test the conjecture that there is at least one prime between each pair of consecutive square numbers. (The square numbers are 1, 4, 9, 16, 25, . . .). Use the Primes class from Problem 2.22. Your first five lines of output should look like this:
Problem 2.22
Define and test a Primes class with these methods: Use the BitSet implementation of the Sieve of Eratosthenes from Problem 2.21. Use these definitions: including this static initializer, which implements the Sieve of Eratosthenes:
Problem 2.21
Repeat Problem 2.19 using a java.util.BitSet object.
Problem 2.19
The Sieve of Eratosthenes is an array of boolean elements whose ith element is true if and only if i is a prime number. Use the following algorithm to compute and print a sieve of size 1000: (Precondition: p is an array of n bits.) (Postcondition: p[i] is true if and only if i is prime.) 1. Initialize p[0] and p[1] to be false, and all other p[i] to be true. 2. Repeat step 3 for each i from 3 to n, incrementing by 2. 3. If there is a prime the square root of i that divides i, set p[i] false.