9 lines
154 B
Matlab
9 lines
154 B
Matlab
function printfactorial(n)
|
|
% compute the factorial of n and print it
|
|
x = 1;
|
|
for i = 1:n
|
|
x = x * i;
|
|
end
|
|
fprintf('Factorial of %i is: %i\n', n, x)
|
|
end
|