Fibonacci numbers in Basic
Example for versions
Microsoft Visual Basic .NET 9 (2008),
vbnc 2.4.2
This example uses recursive definition of Fibonacci numbers.
Module Module1
Function Fibonacci(ByVal n As Integer) As Long
If n < 3 Then
Return 1
Else
Return Fibonacci(n - 1) + Fibonacci(n - 2)
End If
End Function
Sub Main()
For i As Integer = 1 To 16
Console.Write(Fibonacci(i) & ", ")
Next
Console.WriteLine("...")
End Sub
End Module
Comments
]]>blog comments powered by Disqus
]]>