Public Class Form1
Private Function fib()
Dim result As Integer
If (NUD1.Value < 2) Then
result = 1
Return result
Else
result = fib(NUD1.Value - 1) + fib(NUD1.Value - 2)
Return result
End If
End Function
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
LbFb1.Items.Add(fib())
End Sub
结束类
出于某种原因,它只返回 0,1 的值,如果我超过 2,它就会崩溃。有什么想法吗?