Advertisement
PROFESSOR_AIH

Easy Fibonacci

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