Factors of an integer: Difference between revisions
m
alphabetized list; changed realbasic lang tag to vb
(Undo revision 101016 by 81.255.154.129 (previous version worked fine; no need to make it more complex)) |
m (alphabetized list; changed realbasic lang tag to vb) |
||
Line 1,116:
[1] 1 2 4 8 16 32 64
</lang>
=={{header|REALbasic}}==▼
<lang vb>Function factors(num As UInt64) As UInt64()▼
Dim result() As UInt64▼
Dim iFactor As UInt64 = 1▼
If num Mod iFactor = 0 Then▼
result.Append(iFactor)▼
End If▼
iFactor = iFactor + 1▼
Wend▼
Return result▼
End Function</lang>▼
=={{header|REXX}}==
Line 1,362 ⟶ 1,377:
n= 200 divisors=1 2 4 5 8 10 20 25 40 50 100 200
</pre>
▲=={{header|REALbasic}}==
▲Function factors(num As UInt64) As UInt64()
▲//This function accepts an unsigned 64 bit integer as input and returns an array of unsigned 64 bit integers
▲ Dim result() As UInt64
▲ Dim iFactor As UInt64 = 1
▲ While iFactor <= num/2 //Since a factor will never be larger than half of the number
▲ If num Mod iFactor = 0 Then
▲ result.Append(iFactor)
▲ End If
▲ iFactor = iFactor + 1
▲ Wend
▲ iFactor.Append(num) //Since a given number is always a factor of itself
▲ Return result
▲End Function
=={{header|Ruby}}==
Line 1,402 ⟶ 1,401:
[1, 53]
[1, 2, 4, 8, 16, 32, 64]</pre>
=={{header|Sather}}==
{{trans|C++}}
Line 1,452:
Output:
(1 239 4649 1111111)
=={{header|Slate}}==
<lang slate>
|