Pregunta de entrevista de Datadog

Solve a classic recursion problem, then come up with a non recursive solution.