#include<stdio.h>
double fac(int x,int n);
int main()
{
int x,n;
printf("请输入x和n:");
scanf("%d,%d",&x,&n);
p=fac(x,n);
printf("%lf\n",p);
getchar();
getchar();
return 0;
}
double fac(int x,int n)
{
double p;//函数值p应定义为double类型,结果为浮点型;
if(n==0)
return 1;
else
if(n==1)
return x;
else
return ((2n-1)*x-fac(x,n-1)-(n-1)*fac(x,n-2))/n;
return p;
}
运行结果如图所示: