|
-
Jan 5th, 2001, 07:37 PM
#1
Thread Starter
Addicted Member
Are they any pre-established Factoring functions? If not then what is the most efficient way to go about it? All I need to be able to get integers out of it. I mean simple lil numbers such as 32, 24, 10, 12, 2...etc etc. And not even completely factored, just the first two factors. Any formulas, ideas or code greatly appreciated! Thanks!
Cbomb
Techie 
-
Jan 5th, 2001, 07:58 PM
#2
Frenzied Member
I have no way to test this, but wouldn't this work?
Code:
' this function takes a long and returns an array of its factors
Private Sub GetFactors(lngNumber As Long) As Long()
dim lngCounter As Long
dim intElements As Integer
For lngCounter = 1 to lngNumber
If Mod(lngNumber, lngCounter) = 0 Then
intElements = intElements + 1
Redim Preserve GetFactors(intElements)
GetFactors(intElements) = lngCounter
End If
Next ' lngCounter
End Sub
Hope that helps!
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
|