Fibonacci Series
This algorithm finds the fibonacci series. In this algorithm the next number is found by adding up the two numbers before it.
Example of fibonacci series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
Public Shared Function Fibonacci(count As Integer) As Integer()
Dim numbers As Integer() = New Integer(count - 1) {}
If count > 1 Then
numbers(0) = 0
numbers(1) = 1
End If
Dim i As Integer = 2
While i < count
numbers(i) = numbers(i - 1) + numbers(i - 2)
i += 1
End While
Return numbers
End Function
Example
Dim fibonacciNumbers = Fibonacci(10)
Output
0
1
1
2
3
5
8
13
21
34