Pergunta de entrevista da empresa Google

A question which requires basic understanding of functions and loops to solve.