vb作业 编写一个判断素数的函数

来源:百度知道 编辑:UC知道 时间:2024/05/13 05:17:13
救命啊!

Function IsPrime(ByVal N As Integer) As Boolean
Dim i As Integer
IsPrime = True
For i = 2 To N - 1
If N Mod i = 0 Then
IsPrime = False
Exit Function
End If
Next i
End Function

public Is素数(int num)
{
return num为素数?true:false;
}

<html><body>
<script language="vbscript">
num=inputbox("请输入一个你要判断的数")
for i=2 to num-1
if (num mod i)=0 then
windows.alert("不是素数!")
end if
next
</script>
</body></html>

二楼的大侠写的函数好简单哦,可是我看不懂.
有谁懂的指点一下我啊?