Simplicity Consulting interview question

Code this for me and expalin why