Pergunta de entrevista da empresa Google

coding question was asked..simple one using for loop