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

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/26 17:41:27
用VB求1000以内的素数,水仙花,斐波那契数列.
xRKAWp.(RZuvuϒ"]*uJNJ$ݵl"܁=pq!q8,.nEYxju 7< e6θip0 -G]ҦP]9Xu .;ݰYǷh%}d]_*u^Pag"CBi; J=X8\WC WG] X6JRO*IUW:qtsKBW""*J[4iCr`c%&g+2E]V:8`?#q-G 

用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