Question: Write a function in Matlab that checks whether a given number is prime or not. Assume that the input to the function is a natural

Write a function in Matlab that checks whether a given number is prime or not. Assume that
the input to the function is a natural number less than 100. Generate a random integer between 1 and 100
using randi and test your function. Do not use Matlabs inbuilt prime function.
Hint: Run a loop from 1 to n/2, where n is the input. For each value, check whether n divided by the loop
variable is a whole number.

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 Programming Questions!