This program calculates the Fibonacci sequence using recursion.
- The program defines a recursive function
fibonacci(int n)to compute the nth Fibonacci number. - The
main()function initializesnto 5 and prints the corresponding Fibonacci number. - The program uses standard C libraries (
stdio.h) for input and output.
- Compile the program using a C compiler:
- Run the program:
- The output will display:
- The current implementation is recursive, which may not be efficient for large values of
n. - Consider using an iterative approach or memoization for optimization.
Created by Amrendra singh