Question: Question 1 ( 6 0 points ) This question requires you to write a MATLAB script that includes the following functions, and will perform the

Question 1(60 points)
This question requires you to write a MATLAB script that includes the following functions, and will perform
the steps listed below the functions. Do not use any built-in MATLAB functions for this task.
Functions:
1. Write a function named Factors(num) that takes an integer and returns an array of all possible
factors of the num as well as the time (in microseconds) it took to compute it. For example, if num is
18, the function should return 1,2,3,6,9, and 18 and computation time.
2. Write a function named Factorial(num) that takes an integer as an argument and returns its
factorial as well as the time (in microseconds) it took to compute the factorial. For example, if num is
5, the function should return 120(5!) and computation time.
3. Write a function named PrimeNumbers(num) that takes an integer as an argument and returns an
array of all prime numbers less than or equal to num as well as the time (in microseconds) it took to
compute it.
Script: Your script should perform the following steps:
1. After receiving input from the user, the program should check whether the input is between 500 and
1000. If the number passes this condition, the script should continue its other steps. If the condition is
not met, the script should output The input is not between 500 and 1000 and ask the user for input
again.
2. In the next step, the program should check whether the input is indeed an integer and not a prime
number. If the input is not an integer, it should be rounded up to the next integer. If the input is a
prime number, add 1 to make it non-prime.
3. Call your Factors(num) function and print the array and computation time.
4. Call your Factorial(num) function and print the result and computation time.
5. Call your PrimeNumbers(num) function and print the result and computation time.
6. plot all three times using a bar graph.

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!