GlobalLogic interview question

they asked me to write some codes using recursion.