Created
May 8, 2015 22:36
-
-
Save micylt/1b4e4644757916a07992 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns whether given integer is a perfect number or not | |
public boolean perfectNumber(int number) { | |
int temp = 0; | |
for(int i= 1; i <= number/2; i++) { | |
if(number % i == 0) { | |
temp += i; | |
} | |
} | |
if(temp == number) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment