Do[
f[x_]:=m x;
a[k_]:=(2/L)Integrate[f[x] Cos[2 k Pi x/L],{x,l,u}];
b[k_]:=(2/L)Integrate[f[x] Sin[2 k Pi x/L],{x,l,u}];
a[0]=(1/(u-l))Integrate[f[x],{x,l,u}];
Print["a[0]=",a[0]];
Print["a[k]=",a[k]];
Print["b[k]=",b[k]];
F[x_]:=a[0]+Sum[a[k]Cos[k Pi x/L]+b[k]Sin[k Pi x/L],{k,1,n}];
(*Print["n=",n];
Plot[F[x],{x,-5L,5L},PlotRange->{-2,2}];*)
,{n,1,1}];

m=2;L=1;
a[0]=m L/2;b[k_]:=-m L/(Pi k);
Do[
F[x_]:=a[0]+Sum[ b[k] Sin[2Pi k x/L],{k,1,n}];
Print["n=",n," m= ",m," L=",L];
Plot[F[x],{x,-2L,2L},PlotRange->{-m L,m L}];
,{n,1,50}];