?If

f[t_]=If[0<t<1,t,If[1<t<3,2-t,t-4]];

p1=Plot[f[t],{t,0,4},PlotStyle->RGBColor[1,0,0]]

T=4; ω = 2 π/T

a[n_]= 2/T Integrate[Cos[n ω t]*f[t],{t,0,T},Assumptions->Element[n,Integers]]//Simplify

a[0]=Limit[a[n],n->0]

Table[{n,a[n]},{n,0,10}]//TableForm

b[n_]= 2/T Integrate[Sin[n ω t]*f[t],{t,0,T},Assumptions->Element[n,Integers]]//Simplify

Table[{n,b[n]},{n,1,10}]//TableForm

q[t_,n_] :=Sum[b[k]*Sin[k ω t],{k,1,n}]

p2=Plot[q[t,40],{t,0,T}]

Show[p1,p2]