Simple java judge solution


  • 0
    X

    For explaining of perfect number, just see wikipedia;
    https://en.wikipedia.org/wiki/Perfect_number

    In range of the 1 ~ 1e8, there are only 5 perfect numbers;

    6, 28, 496, 8128, 33550336

    private static final int[] perfectNumber = {6, 28, 496, 8128, 33550336};
        
        public boolean checkPerfectNumber(int num) {
            if(num <= 0){
                return false;
            }
            for(int i = 0; i < perfectNumber.length; i++){
                if(num == perfectNumber[i]){
                    return true;
                }
            }
            return false;
        }
    

  • 0
    G

    @xiaowu4 ....this is like filling in the answer after take a peek into the cheatsheet....


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.