f[x_] := 
        Which[-Pi < x < -(Pi/2), 0, -(Pi/2) < x < (Pi/2), 1, 
          (Pi/2) < x < Pi, 0];
a0 = 
      (1/(2*Pi))*(∫_(-(Pi/2))^((Pi/2)))1 \[DifferentialD]x
an = 
      (1/Pi)*(∫_(-(Pi/2))^((Pi/2)))1*
            Cos[n*x] \[DifferentialD]x
bn = 
      (1/Pi)*(∫_(-(Pi/2))^((Pi/2)))1*
            Sin[n*x] \[DifferentialD]x

c0 = 
      (1/(2*Pi))*(∫_(-(Pi/2))^((Pi/2)))1 \[DifferentialD]x
cn = 
      (1/(2*Pi))*(∫_(-(Pi/2))^((Pi/2)))(E^(-I*n*x)) \[DifferentialD]x