Neo Financial interview question

Write a pseudo code for the following problem.