Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int fibo(int n)
- {
- if (n == 1 || n == 2)
- {
- //cout << 1;
- return 1;
- }
- else
- return fibo(n - 1) + fibo(n - 2);
- }
- int main()
- {
- int n;
- int d=1;
- cout<<" nhap n: ";
- cin>>n;
- while (d >= 1)
- {
- int k = fibo(d);
- if (k <= n)
- {
- cout << k<<" ";
- d++;
- }
- else break;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement