Answer to Question #294667 in C for Suvedhaa

Question #294667

Apply the mathematical formula to find fibonacci of the given number using recursive functions? Sample 1 Input : 5, Output : 3. Sample 2 Input : 12, Output : 144



1
Expert's answer
2022-02-07T12:50:48-0500
#include<stdio.h>


int Fibonacci(int n){
	if ( n == 0 ){
		return 0;
	}else if ( n == 1 ){
		return 1;
	}
	return (Fibonacci(n-1) + Fibonacci(n-2));
}


int main(){
	int n;
	scanf("%d",&n);
	if(n<10){
		n-=1;
	}
	printf("Fibonacci number: %d\n", Fibonacci(n));
	
	scanf("%d",&n);
	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