Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (29 sloc) 509 Bytes
/*
This program recurssively finds and prints the fibonacci number.
By: randerson112358
4/7/2014
*/
# include<stdio.h>
int fib(int n);
int main(void)
{
int i;
int n;
printf("Input the index of the fibinocci sequence\n");
scanf("%d", &n);
printf("\nThe first %d fibonacci series numbers\n", n);
for(i=0; i<=n; i++)
{
printf("%d ", fib(i));
}
printf("\n\n");
system("pause");
}
int fib(int n)
{
if(n== 0)
return 0;
if(n==1)
return 1;
return fib(n-1) + fib(n-2);
}