Computer Science, asked by estherroyin, 1 year ago

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?
16wh1a0520: 6 is a perfect number because the proper factors (1,2,3) sum up to 6. [1+2+3 = 6]
estherroyin: But its look.. The sec image of program

Answers

Answered by 16wh1a0520
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