A positive integer number n is said to be perfect if it is equal to the sum of its proper

divisors. In other words, n is equal to the sum of its positive divisors excluding itself. For

example, 6 and 28 are perfect numbers. Indeed, we have:

6 = 1 + 2 + 3

28 = 1 + 2 + 4 + 7 + 14

Assume that the input contains a sequence of integers, each of which could be negative,

positive, or equal to zero. Moreover, this sequence ends with the integer ā1.

2

1. Write a C++ program that reads a sequence of integers and saves it into an array. Your

program has to check whether each integer n in the sequence is perfect using a brute

force approach. That is, your program should use all possible divisors of n from 2 to nā1.

2. Is it possible to optimize the above C++ program? Explain your answer