C-Program to find Fibonacci of a number using Recursion

#include<stdio.h>
void FibonacciCreate(int);
 
int main() {
 
	int k, n;
	long int i = 0, j = 1, f;
 
	printf("Enter the range of the Fibonacci series: ");
	scanf("%d", &n);
 
	printf("Fibonacci Series: ");
	printf("%d\n %d\n ", 0, 1);
	FibonacciCreate(n);
 
	return 0;
}
 
void FibonacciCreate(int n) {
 
	static long int first = 0, second = 1, sum;
 
	if (n > 0) {
		sum = first + second;
		first = second;
		second = sum;
		printf("%ld \n", sum);
		FibonacciCreate(n - 1);
	}
 
}
Capture.PNG
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s