MathWorks Interview Question

How to code a factorial function