Find the Fourier sine coefficients for f(x)=x

(1/π)Integrate[x*Sin[k x],{x,-Pi,Pi}]

Simplify[(1/π)Integrate[x*Sin[k x],{x,-Pi,Pi}],Assumptions->k∈Integers]

b[k_]:=-((2 (((-1))^k))/k)

b/@Range[10]

Manipulate[
Plot[
{x,Sum[b[k]Sin[k x],{k,1,max}]},
{x,-10,10}],
{max,1,100,1}]

Find the Fourier series for f(x)=|x|

Find the Fourier coefficients (Subscript[a, k]):

a[k_]:=Simplify[(2/π)Integrate[x Cos[k x],{x,0,π}],Assumptions->k∈Integers]

a[k]

a/@Range[0,10]

((a[0])/2)+Sum[a[k]Cos[k x],{k,1,6}]

Plot f(x)=|x|and its Fourier series:

a[k_]:=((2 (-1+(((-1))^k)))/((k^2) π))

Manipulate[
Plot[
{Abs[x],(π/2)+Sum[a[k]Cos[k x],{k,1,max}]},
{x,-10,10},PlotRange->{-1,4}],
{max,1,20,1}]