作业帮 > 综合 > 作业

vbvbvbvbvb定义一个判断素数的函数过程,调用该函数过程求出所有的绝对素数

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 04:35:18
vbvbvbvbvb定义一个判断素数的函数过程,调用该函数过程求出所有的绝对素数
vbvbvbvbvb定义一个判断素数的函数过程,调用该函数过程求出所有的绝对素数
Private Function prime(ByVal n As Long) As Integer
Dim k As Integer
prime = False
For k = 2 To Int(Sqr(n))
If n Mod k = 0 Then Exit Function
Next k
prime = True
End Function
Private Function nx(ByVal n As Long) As Long
Dim p As Integer, s As String
Do While n 0
p = n Mod 10
n = n \ 10
s = s & p
Loop
nx = Val(s)
End Function
Private Sub Command1_Click()
Dim m As Long, n As Long, i As Long
For m = 1 To 100 Step 2
n = nx(m)
If prime(m) And prime(n) And m n Then
List1.AddItem "(" & m & "," & n & ")"
End If
Next m
End Sub
Private Sub Command2_Click()
List1.Clear
End Su