Please help me with this Java program
Write a program to input and check whether it is a perfect number or not?
I got 6 as not perfect number . Can you explain and find the mistake in my program
Attachments:
estherroyin:
But 6 is a perfect no right?
Answers
Answered by
2
You should not consider c till n. That is the for loop should be made to run from 1 to n-1 and not 1 to n.
please make changes in the for loop:
for (c = 1; c < n; c++) instead of for(c =1; c <=n; c++)
Similar questions
Science,
7 months ago
English,
7 months ago
Math,
1 year ago
Computer Science,
1 year ago
Science,
1 year ago