This is just an empirical formula found by Kaiser for determining the necessary filter length for a given transition width. That formula is given as Equation $(7.30)$ on page $332$: $$M=\frac{A_s-7.95}{2.285\,\Delta\omega}+1\tag{1}$$ I *think* that Kaiser came up with a formula for determining the filter *order* (hence without the $+1$ in the equation), and the authors of your book preferred to have a formula for the filter *length*, so they took the original formula and added $1$ to it. Judging from some of your previous questions, you seem to be confused when it comes to the terms *filter order* and *filter length*. For FIR filters, filter length is the number of coefficients (taps). Filter order is the (minimum) number of delay elements necessary to implement the filter. It's just like with polynomials: their order is one less than their number of coefficients. E.g., a second-order polynomial has $3$ coefficients: $$P_2(x)=a_2x^2+a_1x+a_0\tag{2}$$ Coming back to FIR filters, you always have $$\textrm{filter length}=\textrm{filter order}+1\tag{3}$$ EDIT: Note that formula $(1)$ above is valid for a Kaiser window, which I chose according to the title of your question. Looking a bit closer at the code, it becomes clear that in the first snippet they actually use a Hamming window, whereas in the second snippet they use a Blackman window. For these windows, there are other formulas for estimating the filter length. These formulas can be found in Table 7.1 (p. 330) of the book you refer to.