MathWorks interview question

How to code a factorial function