Advertisement
Guest User

Fib

a guest
Oct 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int f1 = 0, f2 = 1, f3;
  8. int n;
  9. cin >> n;
  10. for (int i = 1; i < n; ++i) {
  11. f3 = f2+f1;
  12. f1 = f2;
  13. f2 = f3;
  14. }
  15.  
  16. cout << f3 << endl;
  17.  
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement