vb程序 输出一个正整数n的所有因子(包括1和n)
2个回答
展开全部
Private Sub Command1_Click()
Dim i As Long, n As Long, k As Integer
n = Val(InputBox("请输入一个正整数"))
For i = 1 To n / 2
If n Mod i = 0 Then
Print i;
k = k + 1
If k Mod 10 = 0 Then Print
End If
Next i
Print n
Print n; "一共有因数" & k + 1 & "个"
End Sub
Dim i As Long, n As Long, k As Integer
n = Val(InputBox("请输入一个正整数"))
For i = 1 To n / 2
If n Mod i = 0 Then
Print i;
k = k + 1
If k Mod 10 = 0 Then Print
End If
Next i
Print n
Print n; "一共有因数" & k + 1 & "个"
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |