Pergunta de entrevista da empresa Microsoft

How to refactor recursive calls to avoid possible stack overflow?