#include <stdio.h> int main(){ double n,x,y; double p(double n,double x); printf("input n,x(n>=0): "); scanf("%lf,%lf",&n,&x); //方程pn(x) y=p(n,x); printf("the result is %lf ",y); } double p(double n,double x){ double y; if(n==0) y=1; else if(n==1) y=x; if(n>=1) { y=((2*n-1)*x-p(n-1,x)-(n-1)*p(n-2,x))/n;//递归 } return y; }
结果: