Skip to content

Instantly share code, notes, and snippets.

@micylt
Created May 8, 2015 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micylt/1b4e4644757916a07992 to your computer and use it in GitHub Desktop.
Save micylt/1b4e4644757916a07992 to your computer and use it in GitHub Desktop.
// 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