A prime number is an integer greater than unity having no proper divisors.
THE FIRST K PRIMES
Prepare an array P. of K primes.
Unit: internal function
Global variables: the array P.
Parameter: K - number of primes to find
Result: The first K primes are saved into the P. array
In exercise 3, Chapter 4.5.4, D. E. Knuth says: If 1000<=K<=1000000, then K is prime if and only if GCD(K,N)=1; N is the product of the first 168 primes. We can create a simple test function. It returns 1 or 0 depending on whether or not the K, 1000<=K<=1000000, is prime.
THE FIRST 24 MERSENNE PRIMES
Numbers of the form 2**P-1, where P is prime, are known as Mersenne numbers (according Marin Mersenne). The first 24 Mersenne primes are obtained for P equal to 2,3,5,7,...,19937. The following program only displays the number of digits in the Mersenne prime.
Knuth D. E. Seminumerical Algorithms, vol. 2 of The Art of Computer Programming