Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sieve of Eratosthenes Your MIPS assembly program is to determine the number of prime numbers in a given range of values using the simple, ancient

Sieve of Eratosthenes

Your MIPS assembly program is to determine the number of prime numbers in a given range of values using the simple, ancient algorithm proposed by the Greek mathematician, Eratosthenes around 200 B.C.

The algorithm is described in a questionable source as follows:

A prime number is a natural number that has exactly two distinct natural number divisors: 1 and itself.

To find all the prime numbers less than or equal to a given integer n by Eratosthenes' method:

  1. Create a list of consecutive integers from two to n: (2, 3, 4, ..., n),
  2. Initially, let p equal 2, the first prime number,
  3. While enumerating all multiples of p starting from p2, strike them off from the original list,
  4. Find the first number remaining on the list after p (it's the next prime); let p equal this number,
  5. Repeat steps 3 and 4 until p2 is greater than n.
  6. All the remaining numbers in the list are prime.

Use your assembly program to determine the number of prime numbers in the range from 0 to a value entered by the user. Make sure that you inform the user of the limits of your programs ability.

Example Run

Please enter the maximum value to be tested for prime numbers: 15000

In the range of 1-15000, the number of primes is: 1754

Program terminated.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Java Programming, Comprehensive Version

Authors: Y. Daniel Liang

10th Edition

133761312, 978-0133761313

More Books

Students also viewed these Algorithms questions

Question

How might the concept of segmentation be useful to Heather?

Answered: 1 week ago

Question

Find the present value of an annuity

Answered: 1 week ago

Question

Using Gauss-Jordan elimination, invert this matrix ONLY 0 0 0 0 1

Answered: 1 week ago

Question

Identify four methods of studying.

Answered: 1 week ago

Question

31. How does Antabuse work?

Answered: 1 week ago