Public Function fib(ByVal value As Integer) As Integer
Dim x As Stack
x = New Stack(30)
Dim temp As Integer = 1
Dim result As Integer = 0
x.Push(value - 1)
x.Push(value - 2)
While (x.Empty() = False)
temp = x.Pop()
If (temp = 1 Or temp = 0) Then
result = result + temp
Else
x.Push(temp - 1)
x.Push(temp - 2)
End If
End While
Return result
End Function
This post has been edited by macosxnerd101: 23 March 2011 - 05:07 PM
Reason for edit:: Please use code tags

New Topic/Question
Reply



MultiQuote







|