2个回答
展开全部
同时与n互质的数 ------这个不太明白?能说一下吗? 下面1000以内质数算法。
Private Sub Command1_Click()
Text1.Text = ""
For i = 1 To 1000
k = 1
For j = 2 To i / 2
If i Mod j = 0 Then k = 0
Next j
If k = 1 Then
'Print i
Text1.Text = Text1.Text & i & " "
End If
Next i
End Sub
Private Sub Command1_Click()
Text1.Text = ""
For i = 1 To 1000
k = 1
For j = 2 To i / 2
If i Mod j = 0 Then k = 0
Next j
If k = 1 Then
'Print i
Text1.Text = Text1.Text & i & " "
End If
Next i
End Sub
展开全部
Option Explicit
Dim S() As Long
Function HZS(ByVal n As Long)
ReDim S(n) As Long
Dim Tmp1 As Long, Tmp2 As Long, Tmp3 As Long
Dim BL As Boolean
For Tmp1 = 2 To n
BL = True
For Tmp2 = 2 To Tmp1
If Tmp1 Mod Tmp2 = 0 And n Mod Tmp2 = 0 Then
BL = False
Exit For
End If
Next
If BL Then
Tmp3 = Tmp3 + 1
S(Tmp3) = Tmp1
End If
Next
'输出
For Tmp1 = 1 To Tmp3
Print S(Tmp1),
If Tmp1 Mod 5 = 0 Then Print
Next
End Function
Dim S() As Long
Function HZS(ByVal n As Long)
ReDim S(n) As Long
Dim Tmp1 As Long, Tmp2 As Long, Tmp3 As Long
Dim BL As Boolean
For Tmp1 = 2 To n
BL = True
For Tmp2 = 2 To Tmp1
If Tmp1 Mod Tmp2 = 0 And n Mod Tmp2 = 0 Then
BL = False
Exit For
End If
Next
If BL Then
Tmp3 = Tmp3 + 1
S(Tmp3) = Tmp1
End If
Next
'输出
For Tmp1 = 1 To Tmp3
Print S(Tmp1),
If Tmp1 Mod 5 = 0 Then Print
Next
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询