双系遗传百科:vb求100以内的素数的个数

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 13:17:16
麻烦写的详细点行吗
最好是把代码写出来

有25个。

Dim s_Count,i
s_Count=0 '素数个数

For i=2 To 100
s_Count=s_Count+isSushu(i)
Next

MsgBox s_Count

Function isSushu(num) '判断是否素数,是返回1,否返回0
Dim II
For II=2 To Num\2
If (Num Mod II)=0 Then
isSushu=0
Exit Function
End If
Next
isSushu=1
End Function