How to code factorials in Matlab
1.- With iterations (not recommended).
2.- Without iterations (vectorized code, much better option)
3.- Built-in function (this is the obvious way to do it)
More info and details:
http://matrixlab-examples.com/factorials.html