Tle error is comming

#include
using namespace std;

// A recursive function to find nth catalan number
unsigned long int catalan(unsigned int n)
{
// Base case
if (n <= 1)
return 1;

// catalan(n) is sum of
// catalan(i)*catalan(n-i-1)
unsigned long int res = 0;
for (int i = 0; i < n; i++)
    res += catalan(i)
        * catalan(n - i - 1);

return res;

}

// Driver code
int main()
{
int n;
cin>>n;

    cout << catalan(n) << endl;
return 0;

}

hello @mansi25

use dynamic programming to optimise it furthur

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.