1~10000的质数 用 document.write 输出 每行20个 两个数之间5个空格
会的来。谢谢。
1~10000的质数 用 document.write 输出 每行20个 两个数之间5个空格
会的来。谢谢。
Option Explicit
Function Prime(a) As Boolean
Dim i#
For i = 2 To Sqr(a)
If a Mod i = 0 Then
Prime = False
Exit Function
End If
Next i
Prime = True
End Function
Private Sub Command1_Click()
Dim i#, c#
For i = 2 To 1000
If Prime(i) Then
c = c + 1
Open "c:\sushu.txt" For Append As #1
If c Mod 21 <> 0 Then
Print #1, i; Space(5);
Else
Write #1,
End If
Close
End If
DoEvents
Next
End Sub
不会
Private Sub Command1_Click() For i = 1 To 10000 k = 1 For j = 2 To i / 2 If i Mod j = 0 Then k = 0 Next j If k = 1 Then Print i & Space(5); Next i End Sub