#include <stdio.h>
// Function to calculate the nth Fibonacci number
int fibonacci(int n);
int main() {
int n;
// Input: Get the value of n from the user
printf("Enter the value of n: ");
scanf("%d", &n);
// Output: Display the Fibonacci series up to the nth term
printf("Fibonacci Series up to %d terms:\n", n);
for (int i = 0; i < n; i++) {
printf("%d ", fibonacci(i));
}
return 0;
}
// Recursive function to calculate the nth Fibonacci number
int fibonacci(int n) {
if (n <= 1) {
return n;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}