Private Sub Command1_Click()
Dim n As Integer
n = InputBox("请输入第几个月:")
Print "Fib1("; n; ")="; fib1(n)
Print "Fib2("; n; ")="; fib2(n)
End Sub
Function fib1(n As Integer)
a = 1
b = 1
c = 1
For i = 3 To n
c = a + b
a = b
b = c
Next i
fib1 = c
End Function
Function fib2(n As Integer)
If n < 3 Then fib2 = 1 Else fib2 = fib2(n - 1) + fib2(n - 2)
End Function
呵呵,递归和递推法会,但你说的那个斐波那契数列,真不知道是什么东西。