Infosys Interview Question

Apptitues and Coding, Pesudo code