Amazon interview question

Recursion related question, easy to solve