It is much easier to approach the problem of calculating filter coefficients if we simplify the filter equation so that we only have to deal with previous inputs (that is, we exclude the possibility of feedback). The filter equation is then simplified:
If such a filter is subjected to an impulse (a signal consisting of one value followed by zeroes) then its output must necessarily become zero after the impulse has run through the summation. So the impulse response of such a filter must necessarily be finite in duration. Such a filter is called a Finite Impulse Response filter or FIR filter.
The filter's frequency response is also simplified, because all the bottom half goes away:
It so happens that this frequency response is just the Fourier transform of the filter coefficients.
The inverse solution to a Fourier transform is well known: it is simply the inverse Fourier transform.
So the coefficients for an FIR filter can be calculated simply by taking the inverse Fourier transform of the desired frequency response.
Here is a recipe for calculating FIR filter coefficients: