Hey, I am in a beginning C++/C# Class and we are jsut starting the Math LIbrary. I need to write a program that displays all perfect integers up to 100. I am required to write a boolean function, IsPerfect(), to use in the program. My problem is I was either absent or, you know, spaced out, during last chapters which were Classes and objects and Functions. I understand Functions basically, but I am confused with classes. Can someone please gimme some logic and some example code for this, and I can try to deceipher it, (Good practice for me =) ). Thank You!!!!!

Recommended Answers

All 3 Replies

I don't think you'll find anyone here that will provide you with code right from scatch without you showing any effort at all. Post what you think you should do (your code), and I'm sure you'll find lot's of help from that point.

I don't think you'll find anyone here that will provide you with code right from scatch without you showing any effort at all. Post what you think you should do (your code), and I'm sure you'll find lot's of help from that point.

Its not that Im asking for the code of my program neede...I essentially asking for an example of how Math Library is used. I wrote my assignment as an exmaple of the type of Math Library functions I am working with.

I need to write a program that displays all perfect integers up to 100. I am required to write a boolean function, IsPerfect(), to use in the program.

A definition of perfect numbers: a number whose value is the sum of its divisors.

Its not that Im asking for the code of my program neede...I essentially asking for an example of how Math Library is used. I wrote my assignment as an exmaple of the type of Math Library functions I am working with.

You don't need any library functions. You only need the % operator to tell you when a potential divisor is in fact a divisor because it evenly divides into the number. That plus a loop or two and the ability to calculate a sum ought to do. Take a stab at it.

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.