Skip to content

Instantly share code, notes, and snippets.

@0ryant
Created August 8, 2019 10:03
Show Gist options
  • Select an option

  • Save 0ryant/677a8ecae33b76c8767c39ebe26ca817 to your computer and use it in GitHub Desktop.

Select an option

Save 0ryant/677a8ecae33b76c8767c39ebe26ca817 to your computer and use it in GitHub Desktop.
Java - Coding Challenge - isPerfectNumber
public static boolean isPerfectNumber(int number){
if (number<1){
return false;
}
int accum=0;
for (int i=1; i<=(number/2);i++){
if (number%i==0){
accum+=i;
}
}
if (accum==number){
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment