Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean Perfect Number #19

Closed
daveziegler55 opened this issue Dec 7, 2017 · 1 comment
Closed

Boolean Perfect Number #19

daveziegler55 opened this issue Dec 7, 2017 · 1 comment

Comments

@daveziegler55
Copy link

daveziegler55 commented Dec 7, 2017

Hi, I like your solutions. I thought of a different approach to the code for Perfect Number,

public boolean isPerfectNumber(int number){
         
        int temp = 0;
        for(int i=1;i<=number/2;i++){
            if(number%i == 0){
                temp += i;
            }
        }
        if(temp == number){
            System.out.println(""It is a perfect number"");
            return true;
        } else {
            System.out.println(""It is not a perfect number"");
            return false;
        }
@fishercoder1534
Copy link
Owner

Thanks. But it's more time-consuming and it's NOT accepted on Leetcode OJ.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants