Pergunta de entrevista da empresa RELEX Solutions

Solve a simple algorithm question, and explain your steps.