Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function GetNthFibonacciNumber(ByVal n As Integer) As Integer
- Dim NextLast As Integer, Last As Integer, This As Integer
- If n = 0 Then
- Return 0
- ElseIf n = 1 Then
- Return 1
- Else
- NextLast = 0 : Last = 1
- For i As Integer = 2 To n
- This = NextLast + Last
- NextLast = Last
- Last = This
- Next i
- Return This
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement