Fibonacci in Visual Basic

Published on 07 May 2026 (Updated: 07 May 2026)

Welcome to the Fibonacci in Visual Basic page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

Imports System.Numerics

Module Fibonacci

    Public Sub Main(args As String())

        If args.Length = 0 Then
            ShowUsage()
            Return
        End If

        Dim n As Integer

        If Not Integer.TryParse(args(0), n) OrElse n < 0 Then
            ShowUsage()
            Return
        End If

        Dim first As BigInteger = 0
        Dim second As BigInteger = 1

        For i As Integer = 1 To n

            Dim current As BigInteger = first + second
            first = second
            second = current

            Console.WriteLine($"{i}: {first}")

        Next

    End Sub


    Private Sub ShowUsage()
        Console.WriteLine("Usage: please input the count of fibonacci numbers to output")
        Environment.Exit(1)
    End Sub

End Module

Fibonacci in Visual Basic was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.