Write a program that findsall prime numbers up to 10,000,000,000. There are approximately455,052,511 such prime numbers. Your program should meet the followingrequirements:■■ Your program should store the prime numbers in a binary data file, namedPrimeNumbers.dat. When a new prime number is found, the number isappended to the file.■■ To find whether a new number is prime, your program should load the primenumbers from the file to an array of the long type of size 10000. If nonumber in the array is a divisor for the new number, continue to read thenext 10000 prime numbers from the data file, until a divisor is found or allnumbers in the file are read. If no divisor is found, the new number is prime.■■ Since this program takes a long time to finish, you should run it as a batchjob from a UNIX machine. If the machine is shut down and rebooted, yourprogram should resume by using the prime numbers stored in the binary datafile rather than start over from scratch.
Write a
all prime numbers up to 10,000,000,000. There are approximately
455,052,511 such prime numbers. Your program should meet the following
requirements:
■■ Your program should store the prime numbers in a binary data file, named
PrimeNumbers.dat. When a new prime number is found, the number is
appended to the file.
■■ To find whether a new number is prime, your program should load the prime
numbers from the file to an array of the long type of size 10000. If no
number in the array is a divisor for the new number, continue to read the
next 10000 prime numbers from the data file, until a divisor is found or all
numbers in the file are read. If no divisor is found, the new number is prime.
■■ Since this program takes a long time to finish, you should run it as a batch
job from a UNIX machine. If the machine is shut down and rebooted, your
program should resume by using the prime numbers stored in the binary data
file rather than start over from scratch.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images