Private Function Fibonacci(ByVal n As Long) As Long
Dim n1 As Long
Dim n2 As Long
Dim i As Long
If n > 0 Then
If n <= 2 Then
Fibonacci = 1
Else
n1 = 1
n2 = 1
For i = 3 To n - 1
If i And 1 Then
n1 = n1 + n2
Else
n2 = n1 + n2
End If
Next i
Fibonacci = n1 + n2
End If
End If
End Function