编写一个VB程序,找出100以内的孪生素数

在线等待,急~~~
2024-12-17 05:43:01
推荐回答(1个)
回答1:

p=3
for i= 5 to 100 step 2
flag=-1
for j= 3 to int(sqr(i)) step 2
if i mod j = 0 then
flag=0
exit for
end if
next
if flag=-1 then
if i=p+2 then
s=s & "(" & p & "," & i & ")"
end if
p=i
end if
next
msgbox s