Pregunta de entrevista de Philips

How would you make this function