> 
> Determine how many $2020$-digit-numbers simultaneously satisfy these three constraints:
> 
> 
> **i/** every digit of the number is one of the following: $2, 4, 5, 7$;
> 
> 
> **ii/** digits $4$ and $5$ must not stand next to one another;
> 
> 
> **iii/** the number is divisible by $3$.
> 
> 
> 

Let $x\_n, y\_n, z\_n, t\_n$ be the number of $n$-digit-numbers that end with $2, 4, 5, 7$ respectively $(n \in \mathbb Z^+)$.

We have that $x\_n + y\_n + z\_n + t\_n = S\_n$.

(with $S\_n$ being that number of $n$-digit-numbers that satisfy the first two conditions of the problem).

It can be seen that $t\_n = x\_n, y\_n = z\_n \implies \left\{ \begin{align} x\_{n + 1} &= x\_n + 2y\_n\\ y\_{n + 1} &= S\_n\\ S\_{n + 1} &= 2(x\_n + y\_n) \end{align} \right. \implies S\_{n + 2} = 3S\_{n + 1} + 2S\_n$.

There exist constants $p$ and $q$ such that $S\_n$ can always be expressed in the form of $p\alpha^n + q\beta^n$ for $\forall n \in \mathbb Z^+$ where $\alpha$ and $\beta$ are roots of the equation $x^2 - 3x - 2 = 0$.

Furthermore, it can be obtained that $S\_1 = 4$ and $S\_2 = 10$.

$\implies \left\{ \begin{align} \alpha + \beta &= 3\\ \alpha\beta &= - 2\\ p + q &= 4\\ p\alpha + q\beta &= 10 \end{align} \right.$ $\implies \left\{ \begin{align} (\alpha, \beta) = \left(\dfrac{3 + \sqrt{17}}{2}, \dfrac{3 - \sqrt{17}}{2}\right)\\ (p, q) = \left(2 + \dfrac{4}{\sqrt{17}}, 2 - \dfrac{4}{\sqrt{17}}\right)\end{align} \right.$

$$ \implies S\_n = 2\left[\left(1 + \dfrac{2}{\sqrt{17}}\right) \cdot \left(\dfrac{3 + \sqrt{17}}{2}\right)^n + \left(1 + \dfrac{2}{\sqrt{17}}\right) \cdot \left(\dfrac{3 - \sqrt{17}}{2}\right)^n \right]$$