求解这道vb习题
1个回答
展开全部
Private Sub Command1_Click()
Dim i As Integer, n As Integer
Print "100~200间的所有素数:"
For i = 100 To 200
If isprime(i) Then
Print i;
n = n + 1
If n Mod 10 = 0 Then Print
End If
Next i
End Sub
Function isprime(n As Integer) As Boolean
isprime = n > 1
For i = 2 To Sqr(n)
If n Mod i = 0 Then isprime = False: Exit Function
Next i
End Function
Private Sub Command2_Click()
Dim i As Integer, n As Integer
Print "1000以内最大的五个素数:"
For i = 1000 To 1 Step -1
If isprime(i) Then
Print i;
n = n + 1
If n = 5 Then Print: Exit For
End If
Next i
End Sub
追问
请问大佬,for i =2 to sqr(n)是什么意思呀?
还有,哪句程序语言说明是1000以内最大的五个素数呢?最大如何体现的?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询