Answer to Question #294486 in C for Suvedhaa

Question #294486

Apply the mathematical formula to find Fibonacci of the given number


using recursive functions.

1
Expert's answer
2022-02-06T12:30:54-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS