SHARE
TWEET

câu 1

a guest Feb 27th, 2020 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int fibonacci(int n) {
  5.     if (n < 0) {
  6.         return -1;
  7.     }
  8.     if (n <= 1) {
  9.         return n;
  10.     }
  11.     else return fibonacci(n - 1) + fibonacci(n - 2);
  12. }
  13. int main ()
  14. {
  15.     int n;
  16.     cin >> n;
  17.     for (int i = 0; i < n; i++) {
  18.         cout << fibonacci(i) << " ";
  19.     }
  20.     return 0;
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top