Apply the mathematical formula to find Fibonacci of the given number
using recursive functions.
#include <stdio.h>
int Fibonacci(int n) {
if (n < 2) {
return n;
}
return Fibonacci(n-1) + Fibonacci(n-2);
}
int main() {
int n, x;
printf("Enter n: ");
scanf("%d", &n);
x = Fibonacci(n);
printf("The %d-th Fibonacci number is %d\n", n, x);
return 0;
}
Comments
Leave a comment