Philips interview question

How would you make this function