I want to change this function of nested recursion to linear recursion or optimally is tail recursion.
long long x(int n) {
if (n == 0) return 1;
int ret = 0;
for (int i = 0; i < n; ++i) {
ret += (n - i) * (n - i) * x(i);
}
return ret;
}
the origin recursion is
X(0)=1; X(n)=n^2*X(0)+(n-1)^2*X1+...+1^2*X(n-1)