Recursion is a devious construction which allows a function to call itself. Here is a simple example:
function y=twoexp(n) % y=twoexp(n). This is a recursive program % for computing y=2^n. the program halts % only if n is a nonnegative integer. if n==0, y=1; else y=2*twoexp(n-1); end