Pregunta de entrevista de Merrill

Math, programming and some brain teaser.