Created
August 8, 2019 10:03
-
-
Save 0ryant/677a8ecae33b76c8767c39ebe26ca817 to your computer and use it in GitHub Desktop.
Java - Coding Challenge - isPerfectNumber
This file contains hidden or 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
| 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