Question: Create a function my_factorial that takes in an input argument n and returns the factorial of a given number. Factorial of a given integer is
Create a function my_factorial that takes in an input argument n and returns the factorial of a given number. Factorial of a given integer is the product of the integer and all the positive integers it. For instance, if your input is 5, your function should return 120 which is equal to 5x4x3x2x1. You are to implement this function without using any built-in MATLAB function and using only for / while loops. Write a script file run_my_factorial to call the function. Script file should allow the user to enter the value (input command) that he wants to compute factorial for and display the factorial value. However, if the value entered is not in the desired form [Not a positive integer], your code should not terminate (i.e. should not break), instead you should allow the user to re-enter until he enters it as desired. You may assume that user will check only for negative values/ decimal values. You may use round() command if needed. ((use matlab))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
