Hello,

I'm trying to print out on the screen the the sum of a perfect number, and i can't quite figure it out how to code it. For example I now 6 is a perfect number so i need [ 6= 1+2+3 ] to print out on the screen. Any help would be much appreciated

Recommended Answers

All 2 Replies

Start by defining what a perfect number is. Is a perfect number one that equals the sum of it's factors other than itself? If so, then determine all the factors of the number, arrange them in ascending order, and add all but the largest one together. If that sum is the same as the largest factor (that is the same as the number itself) then the number is perfect.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.