Factorials are used for many different applications, such as Taylor series, combinatorial probability, permutations and modelling rate of growth. The factorial of a positive integer n is defined as:

Alternatively, the factorial of n can be written recursively as

(a) Write a function that calculates the factorial using a loop:

function f = MyFactorial(x)

(b) Write an m-file that prompts the user to enter a number and uses the function in part (a) to calculate the factorial.