求高人帮我看看一道普通VB题目!
两质数的差为2,则称此对质数为质数对,找出100以内的质数对并在picturebox中按行成对显示质数对~帮我写下代码~谢谢~...
两质数的差为2,则称此对质数为 质数对,找出100以内的质数对 并在 picturebox中 按行成对显示质数对~
帮我写下代码~谢谢~ 展开
帮我写下代码~谢谢~ 展开
展开全部
Function isprime(Num As Long) As Boolean
If Num < 2 Then isprime = False: Exit Function
Dim i As Long
For i = 2 To Sqr(Num)
If (Num Mod i) = 0 Then
isprime = False
Exit Function
End If
Next i
isprime = True
End Function
Private Sub Command1_Click()
Dim i As Long
i = 3
Do
If isprime(i) And isprime(i + 2) Then Picture1.Print i, i + 2
i = i + 2
Loop Until i = 99
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询