Factorial
Complete the function using a combination of branching and a for-loop to compute a factorial. You may not use the built-in function factorial in this problem. (1) Factorial is only defined for non-negative numbers. If the input n is smaller than 0, the total should be NaN. The example code for computing a running sum is provided below.
total = 0
for i = 1:10
total = total + i
end
Function fact(n)
% compute total = n! using branching and a for-loop
end
Code to call your function:
fact(10)