(* Half-range cosine expansion of t on [0,Pi] *)
(*--------------------------------------------*)

ClearAll["@"];

(*Define, but don't evaluate the Fourier coeffs*)
a[n_]:=2/Pi*Integrate[t*Cos[n*t],{t,0,Pi}]
a[0]=a[0]/2;

(*Evaluate S5 and display*)
S5=Sum[a[n]*Cos[n*t],{n,0,5}]
(*Evaluate S20 but don't display*)
S20=Sum[a[n]*Cos[n*t],{n,0,20}];

(*Plot the approximation curves*)
flist={S5,S20};
Plot[Evaluate[flist],{t,-2Pi,2Pi}]
