Pregunta de entrevista de Siemens

one coding question some puzzles related to mathematics