Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,144 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,066 people online right now. Registration is fast and FREE... Join Now!




perfect numbers

 
Reply to this topicStart new topic

perfect numbers, A program with function which determines perfect numbers and its facto

tarekpk
16 May, 2007 - 01:28 AM
Post #1

New D.I.C Head
*

Joined: 16 May, 2007
Posts: 6


My Contributions
I need a program which uses and call a function that determines perfect numbers between 1 and 1000 and also display its factors.

A perfect number is an integer if the sum of its factors including 1 but not the number itself is equel to the number.For example 6 is a perfect number, because
1 * 2 * 3 = 6 = 1 + 2 + 3
User is offlineProfile CardPM
+Quote Post

AmitTheInfinity
RE: Perfect Numbers
16 May, 2007 - 03:51 AM
Post #2

C Surfing ∞
Group Icon

Joined: 25 Jan, 2007
Posts: 1,025



Thanked: 35 times
Dream Kudos: 125
My Contributions
please show what you have tried first. After that we will be able to help you better.
User is offlineProfile CardPM
+Quote Post

tarekpk
RE: Perfect Numbers
16 May, 2007 - 06:22 AM
Post #3

New D.I.C Head
*

Joined: 16 May, 2007
Posts: 6


My Contributions
I need a program which uses and call a function that determines perfect numbers between 1 and 1000 and also display its factors.

A perfect number is an integer if the sum of its factors including 1 but not the number itself is equel to the number.For example 6 is a perfect number, because
1 * 2 * 3 = 6 = 1 + 2 + 3

User is offlineProfile CardPM
+Quote Post

ajwsurfer
RE: Perfect Numbers
16 May, 2007 - 08:20 AM
Post #4

D.I.C Regular
Group Icon

Joined: 24 Oct, 2006
Posts: 292



Thanked: 2 times
Dream Kudos: 50
My Contributions

First you need all the prime numbers.
Next you need multiples and sums of the prime numbers.

2 * 3,
2 * 5, 3 * 5,
2 * 7, 3 * 7, 5 * 7,
2 * 11, 3 * 11, 5 * 11, 7 * 11,
2 * 13, 3 * 13, 5 * 13, 7 * 13, 11 * 13

2 * 3 * 5, 2 * 3 * 7, 2 * 3 * 11, 2 * 3 * 13,
2 * 5 * 7, 2 * 5 * 11, 2 * 5 * 13,
2 * 7 * 11, 2 * 7 * 13,
2 * 11 * 13

3 * 5 * 7, 3 * 5 * 11, 3 * 5 * 13,
3 * 7 * 11, 3 * 7 * 13,
3 * 11 * 13,

5 * 7 * 11, 5 * 7 * 13
5 * 11 * 13

7 * 11 * 13

2 * 3 * 5 * 7, 2 * 3 * 5 * 11, 2 * 3 * 5 * 13,
2 * 5 * 7 * 11, 2 * 5 * 7 * 13,
2 * 7 * 11 * 13,

3 * 5 * 7 * 11, 3 * 5 * 7 * 13,
3 * 7 * 11 * 13,

5 * 7 * 11 * 13,

2 * 3 * 5 * 7 * 11, 2 * 3 * 5 * 7 * 13,
3 * 5 * 7 * 11 * 13,


2 * 3 * 5 * 7, 2 * 3 * 5 * 11

1. Place all prime numbers in an array or vector
2. Use a for loop to compare sums and factors

User is offlineProfile CardPM
+Quote Post

Trogdor
RE: Perfect Numbers
16 May, 2007 - 09:13 AM
Post #5

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 523



Thanked: 3 times
Dream Kudos: 125
My Contributions
actualy, first, you need to read the forumrules.
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Perfect Numbers
17 May, 2007 - 10:51 AM
Post #6

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,858



Thanked: 49 times
Dream Kudos: 550
My Contributions
lol... might want to read up a little on perfect numbers.

There are only 3 numbers between 0 and 1000 which are perfect: 6, 26, 496. These can be found using a brute force approch or using a formula. The problem with using the formula is that you must prove that there are no OTHER perfect numbers in the range of 0 and 1000 (no one has ever said that the formula finds all perfect numbers, only the first 4).

[EDIT] Topics Merged -- Please do not duplicate topics. [/EDIT]
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 10:45PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month