Programming Exercise 22.8 stores the prime numbers in a file

Programming Exercise 22.8 stores the prime numbers in a file named PrimeNumbers.dat. Write a program that finds the number of prime numbers that are less than or equal to 10, 100, 1,000, 10,000, 100,000, 1,000,000, 10,000,000, 100,000,000, 1,000,000,000, and 10,000,000,000. Your program should read the data from PrimeNumbers.dat.

Write a program that finds 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.

 

Leave a Comment

Your email address will not be published. Required fields are marked *

GradeEssays.com
We are GradeEssays.com, the best college essay writing service. We offer educational and research assistance to assist our customers in managing their academic work. At GradeEssays.com, we promise quality and 100% original essays written from scratch.
Contact Us

Enjoy 24/7 customer support for any queries or concerns you have.

Phone: +1 213 3772458

Email: support@gradeessays.com

© 2024 - GradeEssays.com. All rights reserved.

WE HAVE A GIFT FOR YOU!

15% OFF 🎁

Get 15% OFF on your order with us

Scroll to Top