Results 1 to 8 of 8

Thread: Find the semi perfect numbers

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    Find the semi perfect numbers

    Hi friends,

    I have a question about finding the semi perfect numbers. Semi perfect number: The sum of three biggest divisors of any number apart from the number equals the that number.
    For example:
    6's divisors : 6, 3, 2, 1 >>> 3 + 2 + 1 = 6 This is semi perfect
    30's divisors : 30, 15, 10, 6, 5, 3, 2, 1 >>> 15+10+6 = 31 This isn't semi perfect
    36's divisors : 36, 18, 12, 9, 6, 4, 3, 2, 1 >>> 18+12+9 = 39 This isn't semi perfect
    18's divisors: 18, 9, 6, 3, 2, 1 >>> 9 + 6 + 3 = 18 This is semi perfect.

    I want there is a combobox. In combobox there will be 4 option " 1 2 3 4". When I click "1" it will print the semi perfect numbers in one stage on picturebox. When I click "2" it will print the semi perfect numbers in two stage
    on picturebox.

    I did lots of tries but it didn't work. At least If you give me the diagram, it will be perfect for me.

    Thanks...

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Find the semi perfect numbers

    I suppose this would be a bit like the factors code that is floating around in the maths section somewhere.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Find the semi perfect numbers

    you can try like
    vb Code:
    1. Dim divisors() As Long
    2. ReDim divisors(2)
    3. For i = 4 To 1000 Step 2
    4.     tot = 0
    5.     d = 0
    6.     ReDim divisors(2)
    7.     For j = i / 2 To 1 Step -1
    8.         If i / j = i \ j Then divisors(d) = j:        d = d + 1
    9.         If d = 3 Then Exit For
    10.     Next
    11.     If d = 3 Then
    12.         For k = 0 To 2
    13.             tot = tot + divisors(k)
    14.         Next
    15.         If tot = i Then snums = snums & "; " & tot
    16.     End If
    17. Next
    18. MsgBox Mid(snums, 2)
    someone may have a better solution
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    Re: Find the semi perfect numbers

    Firstly, Thanks for reply Unfortunatelly, it didn't work. You don't need to copy the codes. If you tell the diagram and how I can do, that's enough for me.

  5. #5
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    Re: Find the semi perfect numbers

    Exactly what do you want with your semi perfect thing?

    Do you want to get the largest factors of your numbers and then their sum? If the sum of the 3 biggest divisors exceeds the number itself them they aren't semi perfect, right?

    Or is it something else?

    EDIT: Also what do you mean by "1 stage" and "2 stage" printing?
    If your problem is solved, then drag down the Thread Tools and mark your thread as Resolved.

    If I helped you solve your problem, inflate some air into my ego by rating my post and adding a comment too.

    For notorious issues (elaborate yourself) contact me via PM. I don't answer them in the forums EVER.

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Find the semi perfect numbers

    Unfortunatelly, it didn't work.
    what did not work?
    you got error?
    nothing happen?
    wrong result?

    If you tell the diagram and how I can do
    diagram of what?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  7. #7
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Find the semi perfect numbers

    Quote Originally Posted by westconn1 View Post
    wrong result?
    Well, according to this articles on Wikipedia (which, the below is just one on the subject):

    http://en.wikipedia.org/wiki/Semiperfect_number

    The number 12 is also one of the numbers.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  8. #8
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Find the semi perfect numbers

    Well, according to this articles on Wikipedia (which, the below is just one on the subject):
    i had not read the definition, i was just working with the description as provided by the op,
    The sum of three biggest divisors of any number
    which would not include 12, 6+4+3=13

    but as the op did not specify what the problem was, i can not guess
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width