-
Dec 3rd, 2011, 12:04 AM
#1
Thread Starter
Member
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...
-
Dec 3rd, 2011, 12:54 AM
#2
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
-
Dec 3rd, 2011, 05:24 AM
#3
Re: Find the semi perfect numbers
you can try like
vb Code:
Dim divisors() As Long ReDim divisors(2) For i = 4 To 1000 Step 2 tot = 0 d = 0 ReDim divisors(2) For j = i / 2 To 1 Step -1 If i / j = i \ j Then divisors(d) = j: d = d + 1 If d = 3 Then Exit For Next If d = 3 Then For k = 0 To 2 tot = tot + divisors(k) Next If tot = i Then snums = snums & "; " & tot End If Next 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
-
Dec 3rd, 2011, 09:15 AM
#4
Thread Starter
Member
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.
-
Dec 3rd, 2011, 01:05 PM
#5
Hyperactive Member
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.
-
Dec 3rd, 2011, 08:45 PM
#6
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
-
Dec 3rd, 2011, 09:23 PM
#7
Re: Find the semi perfect numbers
Originally Posted by westconn1
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
-
Dec 3rd, 2011, 10:34 PM
#8
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|