请高人帮忙~~~~~~~~~如何用vbs来解答:输入一个数,判断是素数还是合数?

来源:百度知道 编辑:UC知道 时间:2024/04/28 05:25:56

dim a,b,s,i,j
a=inputbox("输入数字:")
b=a
s=""
for i=2 to int(sqr(a)+1)
j=0
do while b mod i =0
b=b/i
j=j+1
loop
if j>0 then
if j>1 then
s=s & i & "^" & j & "*"
else
s=s & i & "*"
end if
end if
if i>b and b<>1 then s=s & b & "*":b=1
if b=1 then exit for
next
if b<>1 then s=s & b & "*":b=1
if s="" then
s=a & "是素数!"
else
s=left(s,len(s)-1)
if s=a then
s=a & "是素数!"
else
s=a & "=" & s
end if
end if
msgbox s,vbinformation
msgbox "感谢使用",vbinformation

或者
dim i,j,k
j = inputbox("输入数字","判断质数")

for i = 2 to j - 1
if j mod i = 0 then
k = 1
end if
next
if k = 1 then
msgbox "N