-
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!
-
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!