Question: A mips program to check if a number n is a prime number. Here how it should be done: check if the number n is

A mips program to check if a number n is a prime number.

Here how it should be done:

check if the number n is equal to 2,3 or 5 if yes then it`s prime.

check if the number n is divided by 2, 3 or 5 if yes, the number is not a prime.

check in a loop from 0 to root(n) if one of the following number divides n:

1.7+30*i

2.11+30*i

3.13+30*i

17+30*i

19+30*i

23+30*i

29+30*i

31+30*i

here is the algorithm for section 3:

a. initialize an array with the following numbers {7,11,13,17,19,23,29,31} size of the array is 8.

b. run a loop (from j=0 to 8):

another loop inside that runs from i =0 till array[j]+30*i is bigger than the root of n:

if array[j]+30*i divides n return n is not prime

4. return n is prime.

This is the following output if n = 32761:

32761 is NOT a prime number. 32761 = 181 * 181

7919 IS a prime number.

4277611 is NOT a prime number. 4277611 = 13 * 329047

4739677 is NOT a prime number. 4739677 = 677 * 7001

Please make it simple program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!