Amazon Interview Question

Recursion related question, easy to solve