Recursive Method!
/*
=======================================================
N-order de polynomial, n=1, Pn (x) =x;n>=1,
Pn (x) = ((2n-1) x-pn-1 (x)-(n-1) Pn-2 (x))/2.
=======================================================
*/
#include <stdio.h>
#include <math.h>
Double p (int n,double x)
{
if (n==0)
return 1; This step is crucial!
if (n==1)
return x;
Else
Return ((2*n-1) *x-p (n-1,x)-(n-1) *p (n-2,x))/n;
}
void Main ()
{
int n;
Double x,q;
printf ("n=");
scanf ("%d", &n);
printf ("x=");
scanf ("%lf", &x);
Q=p (N,X);
printf ("P (%D,%.2LF) =%.2f\n", n,x,q);
}
/*
=======================================================
Comment: The key is to export n=0, p=1; otherwise the answer is not complete!
=======================================================
*/
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
function Call of C language 13-recursive method to find the value of N-order-de-polynomial