用递归方法求n阶勒让德多项式的值

/*
 Date: 07/03/19 15:40
 Description: 用递归法求n阶勒让德多项式的值
           { 1     n=0
      Pn(x)=  { x     n=1
           { ((2n-1).x-Pn-1(x)-(n-1).Pn-2(x)/n   n>=1
*/

#include<stdio.h>

float Legendre(int x,int n);

int main(void)

{

   int x,n;

   float value;

   printf("Enter the order of the polynomials: ");

     scanf("%d %d",&n,&x);

   printf("n=%d,x=%d ",n,x);

     value=Legendre(x,n);

   printf("P%d(%d)=%6.3f ",n,x,value);

   return 0;

 }

float Legendre(int x,int n)

 {

   float value;

    if(n==0)

       value=1;

    else if(n==1)

       value=x;

    else

       value=((2*n-1)*x-Legendre(x,n-1)-(n-1)*Legendre(x,n-2))/n;

    return value;

 }