

x=0:.01:1;
f=x;

n=input(' Give highest order ')

a0=.0;

fa=a0;

for i=1:n,
    
    an=(-1)^(i+1)*2/(i*pi)
    fa=fa+an*sin(pi*x*i);
    
end

plot(x,f,'r-',x,fa,'b-')