作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/07/18 07:04:06
用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)+' 是素数!')