Simplicity Consulting Interview Question

Code this for me and expalin why