Advertisement
HuynhTheAnh

Bài 1

Feb 21st, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. // Entry.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. // Bài 1 | Huỳnh Thế Anh
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. void Fibo(int n)
  9. {
  10. int a=1,b = 1;
  11. while ( a+b < n )
  12. {
  13. cout << a << " " << b << " ";
  14. a = a + b;
  15. b = b + a;
  16. }
  17. if (a < n) cout << a << " ";
  18. if (b < n) cout << b << " ";
  19. }
  20.  
  21. int main()
  22. {
  23. int n;
  24. cout << "n = " << endl;
  25. cin >> n;
  26. Fibo(n);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement