早教吧 育儿知识 作业答案 考试题库 百科 知识分享

VB输入一个大于2的数,判断是否质数记得是输入一个数希望用inputbox

题目详情
VB 输入一个大于2的数,判断是否质数
记得是输入一个数 希望用inputbox
▼优质解答
答案和解析
对于n 有如下方法,从1到N的根 dim i as integer
dim b as boolean
for i =2 to int(sqrt(n))
if n mod i =0 then
b=true
exit for
endif
next
if b then
不是质数
else
质数
endif