Boolean Perfect Number
daveziegler55 opened this issue · 1 comments
daveziegler55 commented
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 commented
Thanks. But it's more time-consuming and it's NOT accepted on Leetcode OJ.