早教吧 育儿知识 作业答案 考试题库 百科 知识分享

VB求一个数的质数因子错误PrivateSubCommand1Click()DimaAsIntegerDimkAsIntegerDimiAsIntegera=InputBox("输入")Fori=1ToaIfaModi=0Then'判断为因子后执行判断素数Fork=2Toi-1IfiModk=0The

题目详情
VB 求一个数的质数因子 错误Private Sub Command1_Click() Dim a As Integer Dim k As Integer Dim i As Integer a = InputBox("输入") For i = 1 To a If a Mod i = 0 Then '判断为因子后执行判断素数 For k = 2 To i - 1 If i Mod k = 0 Then '判断不是素数后 Exit For '结束当前循环 Else Print Str(i) '否则输出该素数因子 End If Next End If Next End Sub 总是出现错误啊!!!能不能帮我看看怎么改
▼优质解答
答案和解析
Private Sub Command1_Click() Dim a As Integer Dim k As Integer Dim i As Integer Dim f As Boolean a = InputBox("输入") For i = 1 To a If a Mod i = 0 Then '判断为因子后执行判断素数 For k = 2 To i - 1 If...