class Solution { public: boolcheckPerfectNumber(int num){ if(num == 1) { returnfalse; } int sum = 1; int root = sqrt(num) + 1; for(int i = 2; i < root; i++) { if(num % i == 0) { sum += i; if(i * i != num) { sum += num / i; } } } return sum == num; } };