Neo Financial Interview Question

Write a pseudo code for the following problem.