Morgan Stanley Interview Question

How would you write a recursive function and describe a real life example when it is needed.