Anik_Akash

Fibonacci

May 29th, 2020
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int n, first=0, second=1, fibo, count=0;
  6.     scanf("%d", &n);
  7.     while(count<n)
  8.     {
  9.         if(count<=1)
  10.         {
  11.             fibo=count;
  12.         }
  13.         else
  14.         {
  15.             fibo = first+second;
  16.             first = second;
  17.             second = fibo;
  18.         }
  19.        
  20.         printf("%d ", fibo);
  21.         count++;
  22.     }
  23.  
  24.     return 0;
  25. }
RAW Paste Data