你的代码不对,而且没有用递归
double fun(double x, int n)
{
if (n == 1) return 1;
double c = 1;
int d = 1;
double p = 1;
for (int i = 0; i < n - 1; i++)
{
c = c * (0.5 - i);
d *= (i + 1);
p *= x;
}
return fun(x, n - 1) + c / d * p;
}