Here's a Matlab function that returns the factorial of a given positive integer n using recursion:
main.m142 chars9 linesAlternatively, you can use a loop to compute the factorial:
main.m93 chars8 linesIn both cases, you can call the function with a positive integer n as an argument, like this:
main.m29 chars4 lines
gistlibby LogSnag