用powerbuilder 判断一个数m是否是素数急用 ,

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/07 22:58:48

用powerbuilder 判断一个数m是否是素数急用 ,
用powerbuilder 判断一个数m是否是素数
急用 ,

用powerbuilder 判断一个数m是否是素数急用 ,
long m
m=99//这是你想测试的值
long TestNum,TestLimit
If mod(m,2) = 0 Then
messagebox('',string(m)+' 不是素数!')
return
end if
TestNum = 3
TestLimit = m
Do While TestLimit > TestNum
If mod(m,TestNum) = 0 Then
messagebox('',string(m)+' 不是素数!')
return
end if
TestLimit = int(m / TestNum)
TestNum = TestNum + 2
Loop
messagebox('',string(m)+' 是素数!')