Pregunta de entrevista de CityGrid Media

Converting a recursive function to non-recursive version.