Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In MATLAB DO THESE Function 1 . Write a function named Factors ( num ) that takes an integer and returns an array of all

In MATLAB DO THESE Function
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

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Briefly describe how CSMA/CD works.

Answered: 1 week ago

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago