Pergunta de entrevista da empresa CityGrid Media

Converting a recursive function to non-recursive version.