Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Part 1: The Sieve of Eratosthenes:Finding All Prime Numbers up to 1000 Eratosthenes of Cyrene lived approximately 275-195 BC. He was the first to...

commentscreenshotsource code.

  • Attachment 1
  • Attachment 2
  • Attachment 3
Part 1: The Sieve of Eratosthenes:Finding All Prime Numbers up to 1000 Eratosthenes of Cyrene lived approximately 275-195 BC. He was the first to accurately estimate the diameter of the earth. For several decades he served as the director and chieflibrarian of the famous library in Alexandria. He was highly regarded in the ancient world, but unfortunately only fragments of his writing have survived. The algorithm described for this assignment is known as the Sieve of Eratosthenes. Please note: You must use this algorithm for this assignment. No other algorithm for finding prime numbers will be accepted for this assignment, although there are plenty of other andmore sophisticated algorithms available! Here are some guidelines: o Create a list of 1,000 values all of which are set to zero. a Set the first two values to 1. (This is because zero and one are not prime numbers.) . Now, perform the following process on the element with an index of 2: Read through the entire list starting at 4 (the first multiple of 2), 2 at a time, so that every element that isread contains an index which is a multiple of 2 and store a 1 for that element. This will result in a list in which all of the items whose index is a multiple of 2 will have a value of1. . Now, perform the exact same process for the element with an index of 3, starting your scan on the very next multiple of 3 (the one with an index of 6 in this case). For every itemin the list whose index is a multiple of 3, change the value of that element to 1. If your program finds an element which is already 1, there is nothing further to do for the item. 0 Next, you would expect to perform the exact same process on the item with an index of 4 however, since 4 is already set to 1, there is no need to check its multiples andyour program could just move on to the next item, which has an index of 5. . Here is the pattern as you move from one item in the list to the next: If that item has a value of O, perform the process. If it is already 1, skip the process. It is important that youunderstand why you should skip this process when the element you are considering is already 1. 0 Now, repeat this process over and over. When you have finished, you will find that there are array items which still have a value of O and those items' index numbers are theprime numbers which you are seeking. - Your program should print out all of the prime numbers which you have found in neatly aligned columns (with up to 10 prime numbers on every row).
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question