Question: 5 Compute factorial using loops (14 points) Write a M-file function script called calculateFactorial.m to evaluate the factorial function, which is defined as following: NI

 5 Compute factorial using loops (14 points) Write a M-file function

5 Compute factorial using loops (14 points) Write a M-file function script called calculateFactorial.m to evaluate the factorial function, which is defined as following: NI = {N* (N 1)! IN > IN=0 Where N is a positive integer passed as a function argument. The function takes the input value of N and returns the value of NI. The first line of the function should be function output - calculate Factorial(n) Include following chocles on the input and display an appropeinte error message of the check in violated: N should be single number, not multi-valued array (Hint: we length() function) N should be non negative N should be an integer, tot fractional number (Hintime rem() function which caloutes remainder ofter division) Once the luput pas all the checks, evaluate the fivetorial value and store it in output. You may use for loop, while loop, and/or if-else statements As your wbmission include the following: Complete Melile script Evaluated fiction values for lupats N-UN - 2.N-12-4,1-10, N-0613

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!