J.P. Morgan interview question

To write a short program