用VB求1000以内的素数,水仙花,斐波那契数列.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/27 13:11:58
用VB求1000以内的素数,水仙花,斐波那契数列.用VB求1000以内的素数,水仙花,斐波那契数列.用VB求1000以内的素数,水仙花,斐波那契数列.先写两个数列.PublicSubaa()Dimab

用VB求1000以内的素数,水仙花,斐波那契数列.
用VB求1000以内的素数,水仙花,斐波那契数列.

用VB求1000以内的素数,水仙花,斐波那契数列.
先写两个数列.
Public Sub aa()
Dim ab As String
Dim i, j As Integer
Dim a, b As Integer
'素数序列
For i = 1 To 1000
For j = 1 To i
If i Mod j = 0 And j 1 And j i Then
Exit For
End If
Next
If j = i + 1 And i 1 Then ab = ab & " " & i
Next
MsgBox ab
'斐波那契
i = 0
a = 1
b = 1
ab = a & " " & b
Do While i < 1000
i = a + b
a = b
b = i
If i > 1000 Then Exit Do
ab = ab & " " & i
Loop
MsgBox ab
End Sub