3个回答
展开全部
Private Sub Form_Click()
Dim i, j, b As Integer
For i = 1 To 100
For j = 2 To i - 1
If i Mod j = 0 Then Exit For
Next
If j > i - 1 Then b = b + i
Next
Print b
End SuB
最简单的
Dim i, j, b As Integer
For i = 1 To 100
For j = 2 To i - 1
If i Mod j = 0 Then Exit For
Next
If j > i - 1 Then b = b + i
Next
Print b
End SuB
最简单的
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim flag As Boolean, S As Integer
For i = 2 To 100
flag = True
For j = 2 To Int(Sqr(i))
If i Mod j = 0 Then flag = False
Next
If flag Then S = S + i
Next
Print S
End Sub
Dim flag As Boolean, S As Integer
For i = 2 To 100
flag = True
For j = 2 To Int(Sqr(i))
If i Mod j = 0 Then flag = False
Next
If flag Then S = S + i
Next
Print S
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Function Prime(a As Integer) As Boolean
Dim k As Integer, isprime As Boolean
If a < 2 Then
isprime = False
Else
isprime = True
k = 2
Do While k < a
If a Mod k = 0 Then
isprime = False
Exit Do
Else
k = k + 1
End If
Loop
End If
Prime = isprime
End Function
Private Sub Command1_Click()
Dim i As Integer, sum As Integer
For i = 1 To 100
If Prime(i) Then
sum = sum + i
End If
Next i
Print sum
End Sub
Dim k As Integer, isprime As Boolean
If a < 2 Then
isprime = False
Else
isprime = True
k = 2
Do While k < a
If a Mod k = 0 Then
isprime = False
Exit Do
Else
k = k + 1
End If
Loop
End If
Prime = isprime
End Function
Private Sub Command1_Click()
Dim i As Integer, sum As Integer
For i = 1 To 100
If Prime(i) Then
sum = sum + i
End If
Next i
Print sum
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询