Results 1 to 4 of 4

Thread: I need help with an algotrithm

  1. #1

    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.

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Posts
    339
    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


  3. #3
    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

  4. #4
    Senior Member
    Join Date
    Jul 2002
    Posts
    339
    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
  •