光子能量:VB编程 将正整数分解为质因数乘积,如:36=2*2*3*3
来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 16:05:41
快啊
Function test(ByVal a As Integer) As String
Dim tmp As Integer
Dim i As Integer
tmp = a
Dim back As String
For i = 2 To a - 1
While tmp Mod i = 0
tmp = tmp / i
back = back & i & " "
End While
Next
test = back
End Function
调用test(36)时
返回2 2 3 3