Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions fibonacci_series/BASIC/fibonacci.bas
Original file line number Diff line number Diff line change
@@ -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
Binary file added fibonacci_series/BASIC/fibonacci.exe
Binary file not shown.