This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/programming/exercises/faculty.m

8 lines
158 B
Matlab

function x = faculty(n)
% return the faculty of n
x = 1;
for i = 1:n
x = x * i;
end
% x = prod(1:n) % this is a one line alternative to the for loop!
end