Advertisement
owlachno

f

Jan 30th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n = 0, f = 0, i = 0, k1 = 1, k2 = 1;
  6.     cin >> n;
  7.    if (n > 2){
  8.     while (i != n)
  9.     {
  10.       f = k1 + k2;
  11.       k1 = k2;
  12.       k2 = f;
  13.       i++;
  14.     }
  15.     cout << f;
  16.    }
  17.    if (n == 0)
  18.     {
  19.         cout << n;
  20.     }
  21.       if ((n == 1) || (n == 2))
  22.     {
  23.         cout << n;
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement