力扣-507-完美数

    public boolean checkPerfectNumber(int num) {
        int sum = 0;
        for (int i = 1; i <= num / 2; i++)
            if (num % i == 0) sum += i;
        return sum == num;
    }
posted @ 2024-07-27 19:47  YaosGHC  阅读(6)  评论(0编辑  收藏  举报