Infosys interview question

Apptitues and Coding, Pesudo code