double类型,求double类型的费吗数字?
摘要Private Function IsPrime(ByVal n As Double) As BooleanDim pb As Doublepb = n 1IsPrime = TrueFor i =
Private Function IsPrime(ByVal n As Double) As Boolean
Dim pb As Double
pb = n – 1
IsPrime = True
For i = 2 To pb
If n Mod i = 0 Then
IsPrime = False
Exit For
End If
Next i
End Function
Private Sub Command1_Click()
For i = 1 To 17
If IsPrime(2 ^ i + 1) = True Then Print 2 ^ i + 1
Next i
End Sub
Private Function Is2n(ByVal n As Double) As Boolean
Is2n = False
If n = 1 Then
Is2n = True
Exit Function
End If
Dim pb As Double
pb = n / 2
Do While pb >= 2
pb = pb / 2
Loop
If pb = 1 Then
Is2n = True
Else
Is2n = False
End If
End Function