-
February 19th, 2004, 08:40 AM
#1
Member
I need help with an algotrithm
Trying to figure out the algotrithm that will find all perfect numbers between 1 and any given int.
A perfect number is defined as: A perfect number is an integer that is equal to the sum of it's divisors as an example 6 is divisible by 1,2 and 3 and 6=1+2+3.
Any help or ideas would be great, thanks.
-
February 19th, 2004, 01:27 PM
#2
Why don't you tell us what you've got so far (a skeleton is fine), and let us help you by filling up the missing parts?
Peace always,
<jdenny>
Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds
-
February 19th, 2004, 08:19 PM
#3
Member
Here is what i know:
Find how many factors of n - this is where i am confused, i am not exactly sure how to find all the factors, if it matters i am using java to do it....the main reason is i dont know how big to make the array for the factors...
Check to see if the f1 + f2 ... = n
-
February 20th, 2004, 07:40 AM
#4
That's a good start!
For a recent discussion of how to find all the factors of a given integer, follow this thread:
http://www.antionline.com/showthread...hreadid=253049
Then instead of displaying the factors, store them in an array, and check to see if the sum is equal to the integer.
Peace always,
<jdenny>
Always listen to experts. They\'ll tell you what can\'t be done and why. Then go and do it. -- Robert Heinlein
I\'m basically a very lazy person who likes to get credit for things other people actually do. -- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|