Morgan Stanley interview question

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