用VB做:将一个正整数分解质因数

2024-11-21 22:29:34
推荐回答(1个)
回答1:

Sub Fj(M As Integer)
Dim I As Integer
Print M & "=";
Do While M <> 0
For I = 2 To M
If M Mod I = 0 Then
Print I;
M = M \ I
Exit For
End If
Next
If M = 1 Then Exit Do
Print "*";
Loop
End SubPrivate Sub Command1_Click()Dim M As IntegerM = Val(InputBox("输入一个整数:"))
Fj (M)
End Sub