IntegraFEC interview question

How would you solve this programming problem?