Pergunta de entrevista da empresa UBS

How to modify the program, and if we could use "for" code to analyze the result.