请问VB语言中怎么求1到1000的素数分别有哪些
2013-08-18
展开全部
Private Sub Command1_Click()
Dim a As Long
Dim i As Long
Dim k As Long
Dim t
For i = 2 To 1000
t = 0
For k = 2 To i - 1
If i Mod k = 0 Then
t = 1
End If
Next
If t = 0 Then
Print i;
a = a + 1
If a Mod 20 = 0 Then
End If
End If
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim i, s, n, c As Double
i = 3: s = 0
Do While i <= 1000
n = 1: c = 0
Do While n <= i
If i Mod n = 0 Then
c = c + 1
End If
n = n + 1
Loop
If c = 2 Then
s = s + i
End If
i = i + 2
Loop
s = s + 2
Print s
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询