package leetcode;

/**
 * https://leetcode.com/problems/perfect-number/
 */
public class Problem507 {
    public boolean checkPerfectNumber(int num) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem507 prob = new Problem507();
        System.out.println(prob.checkPerfectNumber(28)); // true
    }
}

@@ -156,16 +156,28 @@
     
-// TODO%0A
+if (num == 0) %7B%0A    
     
@@ -202,164 +202,367 @@
     
+  
-%7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem507 prob = new Problem507();%0A        System.out.println(prob.checkPerfectNumber(28)); // true
+  %7D%0A        int sum = 0;%0A        for (int i = 1; i %3C Math.sqrt(num); i++) %7B%0A            if (i == 1) %7B%0A                sum += i;%0A            %7D else %7B%0A                // find the divisor%0A                if (num %25 i == 0) %7B%0A                    sum += i;%0A                    sum += num / i;%0A                %7D%0A            %7D%0A        %7D%0A        return (sum == num);
 %0A   

Solve problem 507