Advertisement
SergeyPGUTI

4.2.17

Oct 1st, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n,p=1,p2=1,i=3,Q;
  9.     cin>>n;
  10.     while(i<=n)
  11.     {
  12.         Q=p;
  13.         p=p+p2;
  14.         p2=Q;
  15.         i++;
  16.     }
  17.     if (i>2) cout<<p;
  18.      else cout<<1;
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement