How can you write out the nth derivative of sin(x)?
Let $\displaystyle f(x)=\sin x$
$\displaystyle f'(x)=\cos x$
$\displaystyle f''(x)=-\sin x$
$\displaystyle f'''(x)=-\cos x$
$\displaystyle f''''(x)=\sin x$ and then the cycle repeats
So you could just write it out using if's and keep dividing the n of$\displaystyle f^{(n)} $by 4 to get the remainder
But upon further analysis, we realize
$\displaystyle f'(x)=\cos x=\sin (\frac{\pi}{2}+x)$
$\displaystyle f''(x)=-\sin x=\sin(\frac{2\pi}{2}+x)$
$\displaystyle f'''(x)=-\cos x=\sin(\frac{3\pi}{2}+x)$
$\displaystyle f''''(x)=\sin x=\sin(\frac{4\pi}{2}+x)$
So $\displaystyle f^{(n)}(x)=\sin(\frac{n\pi}{2}+x)$