Algebraic way to see why only $n=3$ is a valid coefficient I'm a bit of a sucker for brute force calculations. Say I want to calculate a coefficient with Fourier theory, in my case
\begin{align*}
a_n = \int_0^1 \sin (3\pi x) \cos (n\pi x) dx.
\end{align*}
Clearly, only $a_3$ is nonzero. But if I calculate this integral explicitly, I get
\begin{align*}
a_n = \frac{3(-1)^{n+1} - 3}{\pi(n^2-9)}.
\end{align*}
I'm not immediately seeing that only $n=3$ will yield a nonzero result here... So how can I evaluate the integral so that only $a_3$ remains?

EDIT: Some extra notes on my calculation. We have
\begin{align*}
I = \int \sin(3\pi x)\cos(n\pi x) dx = \int u \frac{dv}{dx} dx,
\end{align*}
where
\begin{align*}
u = \sin(3\pi x) \Rightarrow \frac{du}{dx} = 3\pi \cos(3\pi x),\\
\frac{dv}{dx} = \cos(n\pi x) \Rightarrow v = \frac1{n\pi}\sin(n\pi x),
\end{align*}
such that
\begin{align*}
I &= \sin(3\pi x) \cdot \frac1{n\pi}\sin(n\pi x) - \int 3\pi \cos(3\pi x) \cdot \frac1{n\pi}\sin(n\pi x) dx \\
&= \frac1{n\pi}\sin(3\pi x)\sin(n\pi x) - \frac 3n\int \cos(3\pi x)\sin(n\pi x) dx \\
&= \frac1{n\pi}\sin(3\pi x)\sin(n\pi x) - \frac 3n J.
\end{align*}
Now repeat the calculation with $J$,
\begin{align*}
J = \int \cos(3\pi x)\sin(n\pi x) dx
\end{align*}
where
\begin{align*}
u = \cos(3\pi x) \Rightarrow \frac{du}{dx} = -3\pi \sin(3\pi x),\\
\frac{dv}{dx} = \sin(n\pi x) \Rightarrow v = -\frac1{n\pi}\cos(n\pi x),
\end{align*}
such that
\begin{align*}
J &= \cos(3\pi x) \cdot \left(-\frac1{n\pi}\cos(n\pi x)\right) - \int 3\pi \sin(3\pi x) \cdot \frac1{n\pi}\cos(n\pi x) dx \\
& = -\frac1{n\pi}\cos(3\pi x) \cos(n\pi x) - \frac3n \int \sin(3\pi x) \cos(n\pi x) dx \\
& = -\frac1{n\pi}\cos(3\pi x) \cos(n\pi x) - \frac3n I
\end{align*}
Plugging in $J$ in the expression for $I$, we get
\begin{align*}
I &= \frac1{n\pi}\sin(3\pi x)\sin(n\pi x) - \frac 3n J \\
&= \frac1{n\pi}\sin(3\pi x)\sin(n\pi x) - \frac 3n \left[-\frac1{n\pi}\cos(3\pi x) \cos(n\pi x) - \frac3n I\right] \\
&= \frac1{n\pi}\sin(3\pi x)\sin(n\pi x) + \frac3{n^2\pi}\cos(3\pi x) \cos(n\pi x) + \frac9{n^2} I \\
I &= \frac{\frac1{n\pi}\sin(3\pi x)\sin(n\pi x) + \frac3{n^2\pi}\cos(3\pi x) \cos(n\pi x)}{1-\frac9{n^2}} \\
&= \frac1\pi \frac{n\sin(3\pi x)\sin(n\pi x) + 3\cos(3\pi x) \cos(n\pi x)}{n^2-9}.
\end{align*}
On the interval $0 < x < 1$, we then get
\begin{align*}
I \Big|_{0}^1 &= \frac1\pi \frac{n\sin(3\pi)\sin(n\pi) + 3\cos(3\pi) \cos(n\pi)}{n^2-9} - \frac1\pi \frac{n\sin(0)\sin(0) + 3\cos(0) \cos(0)}{n^2-9}\\
&= \frac1\pi \frac{3\cos(3\pi) \cos(n\pi)}{n^2-9} - \frac1\pi \frac{3}{n^2-9} \\
&= \frac1\pi \frac{-3(-1)^n - 3}{n^2-9},
\end{align*}
where in the last step I used $\cos(n\pi) = (-1)^n$.

Considering $$a_n = \int_0^1 \sin (3\pi x) \cos (n\pi x)\, dx$$ we can make the calculations faster using $$\sin(a) \cos(b)=\frac 12\big(\sin(a+b)+\sin(a-b)\big)$$ So $$2a_n=\int_0^1 \sin\big((3+n)\pi x\big)\, dx+\int_0^1 \sin\big((3-n)\pi x\big)\, dx$$ which already shows that, for $n=3$, the second integral disappears.
So $$a_3=\frac{1+\cos (3\pi  )}{2 \pi  (n+3)}=0$$ For the other cases $(n\neq 3)$, after simplifications, $$a_n=-\frac{3 (1+\cos (\pi  n))}{\pi  \left(n^2-9\right)}$$ which implies $$a_{2n+1}=0 \quad \quad  \quad a_{2n}=-\frac{6}{\pi  \left(4 n^2-9\right)}$$
