VB怎么解有关因式分解的题目(10000内的)

来源:百度知道 编辑:UC知道 时间:2024/05/26 01:52:28
VB怎么解有关因式分解的题目(10000内的)
VB怎么解有关因式分解的题目(10000内的)程序代码啊

Private Sub Command1_Click()
a = 1023
Dim y()
b = 0
ReDim y(b)
restart:
For i = 2 To a / 2 + 1
If a Mod i = 0 Then
b = b + 1
ReDim Preserve y(b)
y(b) = i
a = a / i
GoTo restart
End If

If i = Int(a / 2 + 1) Then
b = b + 1
ReDim Preserve y(b)
y(b) = a
Exit For
End If
Next

If UBound(y) <> 0 Then
s = ""
For i = 1 To UBound(y)
s = s & y(i) & " x "
Next
s = Left(s, Len(s) - 2)
Print s
Else
MsgBox "a为素数"
End If
End Sub

容易啊。