Pregunta de entrevista de Neo Financial

Write a pseudo code for the following problem.