Susri

3rd semester

Jan 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int c=0,n,res;
  5.     scanf("%d",&n);
  6.     res=fibo(n);
  7.     while(c<n)
  8.     {
  9.         printf("%d ",fibo(c));
  10.         c++;
  11.     }
  12.     return 0;
  13. }
  14. int fibo(int n)
  15. {
  16.     if(n==0 || n==1)
  17.     {
  18.         return n;
  19.     }
  20.     else
  21.     {
  22.         return (fibo(n-1)+fibo(n-2));
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment