emratmuonhocbichvan(koaiepemnoivayca)

 avatar
NguyenAnhQuan
c_cpp
a year ago
337 B
10
Indexable
Never
#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);
}