Pregunta de entrevista de Amazon

Medium difficulty recursion code question.