Public Class Tester
Public Shared Sub Main
Dim number As Integer = 13
Console.WriteLine("Fibonacci Value is " & Fibonacci(number))
End Sub
' calculate Fibonacci value recusively
Shared Function Fibonacci(ByVal number As Integer) As Long
' check for base cases
If number = 1 OrElse number = 0 Then
Return number
Else
Return Fibonacci(number - 1) + Fibonacci(number - 2)
End If
End Function ' Fibonacci
End Class
|