Pregunta de entrevista de Perennial System

coding problem based on loops