for i= 10 to 100
t=0
for j = 2 to i-1
if i mod j = 0 then t=1
next j
if t=0 then print i
next i
求代码上面打印出来的素数的合!
for i= 10 to 100
t=0
for j = 2 to i-1
if i mod j = 0 then t=1
next j
if t=0 then print i
next i
求代码上面打印出来的素数的合!
Private Sub Form_Click()
Dim s%, k%
s = 0
k = 0
For i = 10 To 100
t = 0
For j = 2 To i - 1
If i Mod j = 0 Then t = 1
Next j
If t = 0 Then s = s + i: k = k + 1: Print i
Next i
Print "10到100之间素数个数共有"; k
Print "10到100之间的素数之和为:"; s
End Sub
For i = 10 To 100 For j = 2 To i - 1 If i Mod j = 0 Then t += i End If Next j Next i
print t
这是很多个值的,当然,最终值是73