判断一个整数是否为素数的通用过程:
Dim i as integer
prime = True
For i =2 to sqr(n)
if n Mod i =0 Then
prime = False
Exit For
End if
Next i
100以内的素数:
For I = 100 to 2 step -1
if prime (I) Then
ReDim preserve S(k)
S(k)=I
k=k+1
Ene if
Next I
5个一行输出:Private Sub Command1_()
Dim i As Integer , j As Integer
Randomize
For i = 1 to UBound(a)
For j = 1 to 5
a(i,j)=I
Form1.print a(i,j)
Next j
From1.print
Next i
End Sub
VB没有接触。。。
C可以,C#或者java也行。。。
关键你是要全部,还是只要计算素数的算法