Pergunta de entrevista da empresa BIS SOFT

A problem related to find an algorithm to some logic.