Article

Fibonacci Series in VB.Net

Fibonacci Series in VB.Net

Fibonacci series means, next number is the sum of previous two numbers for example 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 etc. The first two numbers of Fibonacci series are 0 and 1. Like
0+1=1, 1+1=2, 1+2=3
Here you can see next number is sum of previous two number.

Code for Fibonacci Series in Vb.Net
[php]
Imports System

Namespace ConsoleApp3
Class Program
Private Shared Sub Main(ByVal args As String())
Dim num3, i, number As Integer, num1 As Integer = 0, num2 As Integer = 1
Console.Write("Enter the number of elements: ")
number = Integer.Parse(Console.ReadLine())
Console.Write(num1 & " " & num2 & " ")

For i = 2 To number – 1
num3 = num1 + num2
Console.Write(num3 & " ")
num1 = num2
num2 = num3
Next

Console.ReadLine()
End Sub
End Class
End Namespace

[/php]

Output
fibonacci-series-in-vb-net

Leave a Reply

Your email address will not be published.