#include<stdio.h>
int fib(int);
int main()
{
int n,i;
printf("How many terms?");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("%d\t",fib(i));
}
return 0;
}
int fib(int x)
{
if(x<=2)
return 1;
else
return (fib(x-1)+fib(x-2));
}
No comments:
Post a Comment