3
bool checkPerfectNumber(int num) {4
// we are initialising sum with 1 instead of 0 because 1 will be divisor of7
for (int i = 2; i < sqrt(num); i++) {9
// it checks if both are same factors, for ex, if num=9, i=3, num/i is10
// also equal to 3. It is done so that repeated factors aren't added.14
// we are adding n/i because since we are running the loop for15
// sqrt(num), we will be missing divisors >sqrt(num) so tto include16
// that factor we'll add num/i; for ex if we have 64 as number than 817
// is sqrt but 16 and 32 also divides 64 but our loop won't consider18
// that case; so we are adding num/i, which means with 2 we are adding19
// 32 and with 4 we are adding 16.24
if (sum == num && num != 1) {