#include<stdio.h>
#include<conio.h>
main(){
int n,i;
int fib(int x);
clrscr();
printf("How many number do you want in fibonacci series-\n");
scanf("%d",&n);
printf("Fibonacci series of %d numbers\n",n);
for (i=1;i<=n;i++){
printf("%d ",fib(i));
}
getch();
return 1;
}
int fib(int x){
if (x==1) return 0;
if (x==2) return 1;
return (fib(x-1)+fib(x-2));
}
No comments:
Post a Comment