emratmuonhocbichvan(koaiepemnoivayca)
NguyenAnhQuan
c_cpp
2 years ago
337 B
19
Indexable
#include <iostream>
using namespace std;
#define MAX 300
int Fibo(int);
int main()
{
int x;
cin >> x;
if (1 <= x && x <= 30)
{
cout << Fibo(x);
}
else
{
cout << "So " << x << " khong nam trong khoang [1,30].";
}
}
int Fibo(int x)
{
if (x <= 2) return 1;
return Fibo(x - 1) + Fibo(x - 2);
}Editor is loading...