Pregunta de entrevista de Ariston

the logic for the code was asked.