4s店礼仪培训方案:VB编程 将正整数分解为质因数乘积,如:36=2*2*3*3
来源:百度文库 编辑:查人人中国名人网 时间:2024/05/11 19:46:23
快啊
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