+ 1

Somebody Can Help To Check And Debug My Java Code Please!!!!

I want to write a Java method to check whether an input number is a perfect number. Then, I want to write a Java program to use the method to display first 5 perfect numbers. I had posted the code that I wrote but I just managed to check whether the number is a perfect number. I couldn’t make it to display first 5 perfect numbers. And I really can’t figure out why it can’t be displayed. Any coding god can help me to check if the is any error in my code and help me to debug it? Thank you very much! The code that I’ve written https://code.sololearn.com/c4a12A3a8A10/?ref=app

17th Dec 2020, 2:54 PM
Leong Jing Wei
Leong Jing Wei - avatar
2 ответов
0
Hello, by perfect number do you mean an integer? Like the number "4" is a perfect number, but the number "5.67" is not.
17th Dec 2020, 3:36 PM
Frumkin
Frumkin - avatar
0
Perfect number is a positive integer that is equal to the sum of its proper divisors except itself. For example, 1, 2, 3 and 6 are the divisors of 6. If we add up all the numbers except 6, we end with the sum of 6 itself. 1 + 2 + 3 = 6 = Perfect Number 1 + 2+ 3 + 4 + 5 + 6 + 7 = 28 = Perfect Number
17th Dec 2020, 3:40 PM
Leong Jing Wei
Leong Jing Wei - avatar