%% Author: M. Turhan ÇOBAN
%% Created: 2021-11-18

function Pn= P1(n,x)
  if n==0 
    Pn=1.0;
  elseif n==1 
    Pn=x;
  else
      Pnm1=1.0;
      Pn=x;
      for i=2:n
        i1=i-1;
        Pnp1=((2*i1+1)*x*Pn-i1*Pnm1)/(i1+1);
        Pnm1=Pn;
        Pn=Pnp1;
      endfor 
  endif
endfunction
