diff --git a/fibonacci_series/BASIC/fibonacci.bas b/fibonacci_series/BASIC/fibonacci.bas new file mode 100644 index 0000000..3f38de1 --- /dev/null +++ b/fibonacci_series/BASIC/fibonacci.bas @@ -0,0 +1,27 @@ +' Fibonacci Sequence Generator in FreeBASIC + +Declare Function Fibonacci(ByVal n As Integer) As Integer + +' Main program +Dim As Integer n, i + +Print "Enter the number of terms for Fibonacci sequence: "; +Input n + +Print "Fibonacci of "; n; ": "; +For i = 0 To n - 1 + Print Fibonacci(i); " "; +Next i + +Print ' Print a newline at the end + +' Function to calculate Fibonacci number +Function Fibonacci(ByVal n As Integer) As Integer + If n = 0 Then + Return 0 + ElseIf n = 1 Then + Return 1 + Else + Return Fibonacci(n - 1) + Fibonacci(n - 2) + End If +End Function \ No newline at end of file diff --git a/fibonacci_series/BASIC/fibonacci.exe b/fibonacci_series/BASIC/fibonacci.exe new file mode 100644 index 0000000..1d8e884 Binary files /dev/null and b/fibonacci_series/BASIC/fibonacci.exe differ