How many integers between $1$ and $10^n$ contain $14$? How can we derive a formula to calculate the number of integers between $1$ and $10^n$ that contain the number $14$ (as a string)?
For example, there are $20$ integers from $1$ to $1000$ that contain at least one $14$:

"14","114","140","141","142","143","144","145","146","147","148","149","214","314","414","514","614","714","814","914"


There are $\binom{n-k}{k}$ arrangements of $k$ "$14$"s and $10^{n-2k}$ other digits.
Thus, inclusion-exclusion says there are
$$
\sum_{k=1}^{\lfloor n/2\rfloor}(-1)^{k-1}\binom{n-k}{k}10^{n-2k}\tag{1}
$$
numbers from $1$ to $10^n$ which contain "$14$".
Here are some of the first few values.
$$
\begin{array}{r|l}
n&\text{count}\\
\hline
2&1\\
3&20\\
4&299\\
5&3970\\
6&49401\\
7&590040
\end{array}\tag{2}
$$

Generating Function
Multiply $(1)$ by $x^n$ and sum:
$$
\begin{align}
&\sum_{n=0}^\infty\sum_{k=1}^\infty(-1)^{k-1}\binom{n-k}{n-2k}10^{n-2k}x^n\\
&=\sum_{n=0}^\infty\sum_{k=1}^\infty(-1)^{n-k-1}\binom{-k-1}{n-2k}10^{n-2k}x^{n-2k}x^{2k}\\
&=\sum_{k=1}^\infty(-1)^{k-1}\frac{x^{2k}}{(1-10x)^{k+1}}\\
&=\frac1{10x-1}\frac{\frac{x^2}{10x-1}}{1-\frac{x^2}{10x-1}}\\
&=\frac{x^2}{1-20x+101x^2-10x^3}\tag{3}
\end{align}
$$
which has the Taylor series $x^2+20x^3+299x^4+3970x^5+49401x^6+590040x^7+\dots$

Closed Form
The denominator in $(3)$ says that $c_n$ satisfies
$$
c_n=20c_{n-1}-101c_{n-2}+10c_{n-3}\tag{4}
$$
The characteristic polynomial for $(4)$ is
$$
x^3-20x^2+101x-10\tag{5}
$$
whose roots are
$$
\left\{10,5+\sqrt{24},5-\sqrt{24}\right\}\tag{6}
$$
We can solve $(4)$ in the standard manner for such recurrences to get
$$
c_n=10^n-\frac{(5+\sqrt{24})^{n+1}}{2\sqrt{24}}+\frac{(5-\sqrt{24})^{n+1}}{2\sqrt{24}}\tag{7}
$$
