Factors of an integer: Difference between revisions
Content added Content deleted
(Added REALbasic) |
|||
Line 1,363: | Line 1,363: | ||
Dim result() As UInt64 |
Dim result() As UInt64 |
||
Dim iFactor As UInt64 = 1 |
Dim iFactor As UInt64 = 1 |
||
While iFactor <= num |
While iFactor <= num/2 //Since a factor will never be larger than half of the number |
||
If num Mod iFactor = 0 Then |
If num Mod iFactor = 0 Then |
||
result.Append(iFactor) |
result.Append(iFactor) |
||
Line 1,369: | Line 1,369: | ||
iFactor = iFactor + 1 |
iFactor = iFactor + 1 |
||
Wend |
Wend |
||
iFactor.Append(num) //Since a given number is always a factor of itself |
|||
Return result |
Return result |
||
End Function |
End Function |