Pregunta de entrevista de WorkWave

Solve a rather basic programming problem, pseudocode was fine.