programming-examples/asp/More_Code_Snippets/Fibonacci Value.asp
2019-11-18 14:25:58 +01:00

23 lines
592 B
Plaintext

<%
Function Fibonacci(ByVal intNumber)
If (intNumber = 0 Or intNumber = 1) Then
Fibonacci = intNumber
Else
Fibonacci = Fibonacci(intNumber - 1) + Fibonacci(intNumber - 2)
End If
End Function
%>
And here is how we test the function
<%
'variables to store our numbers
Dim fib1 , fib2
'a couple of values
fib1 = 22
fib2 = 3
'display fibonacci value of values e.g Fibonacci(3)
Response.Write ("The Fibonacci value of " & fib1 & " is " & Fibonacci(fib1) & "<br>")
Response.Write ("The Fibonacci value of " & fib2 & " is " & Fibonacci(fib2) & "<br>")
%>