试用VB程序语言写出主要程序段:求S=1+3+5+7+……+999的值。

来源:百度知道 编辑:UC知道 时间:2024/09/22 06:47:29
试用VB程序语言写出主要程序段:判断一个给定的数X是否是素数。
试用VB程序语言写出主要程序段:求S=1!+2!+3!+……+99!的值

(1)
dim a as integer
a=val(text1.text)
b=1
for i=2 to a/2
if a mod i = 0 then
b=b+1
exit for
end if
next
if b=1 then
msgbox a & "是素数"
else
msgbox a & "不是素数"
end if
(2)
dim s as integer
dim c as integer
s=0
for i=1 to 99
c=1
for j=1 to i
c=c*j
next
s=s+a
next

1.
NumBool=true
for i = 2 to Num/2
if Num mod i = 0 then
msgbox Num & "不是一个素数"
NumBool =False
Exit For
end if
next i
if NumBool then msgbox Num & "是一个素数"
2.
Dim Num as long
Dim NumE as long
Num=0
for i = 1 to 99
NumE=1
for j = 1 to i
NumE=NumE*j
next j
Num=Num+NumE
next i

1.
dim flag as bealoon
flag=false
for i=2 to (x-1)
if x mod i=0 then