Capgemini interview question

Pseudo code