double类型,求double类型的费吗数字?

2022-02-06 13:52:48 百科大全 投稿:一盘搜百科
摘要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

double类型,求double类型的费吗数字?插图

Dim pb As Double

double类型,求double类型的费吗数字?插图1

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

声明:一盘搜百科所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系 88888@qq.com