Let $z_i = \alpha^i + \beta^i + \gamma^i$
It's easy to check that $z_0 = 3, z_1 = 7, z_2 = 25$ etc.
Our objective is to compute $z_{21007} \bmod 10000$
Consider the sequence of rational integers $3, 7, 25, \ldots$
and the corresponding recurrence relation $$z_{n+3} - 7z_{n+2} + 12z_{n+1} - 11z_n = 0$$
We'll find the periodicity of the above sequence modulo $10000 = 2^4 5^4$
We'll do it in $3$ steps and need $3$ theorems (viz., Theorems $2, 8, 10$) from On sequences defined by linear recurrence relations by H. T. Engstrom
$1.$ Find the periodicity modulo $2$ and modulo $5$ (See Theorem $2$)
Consider $$F(z) = z^3 - 7z^2 + 12z - 11 = 0$$
Or, $$F(z) \bmod 2 = (z^3 + z^2 + 1) \bmod 2$$
and $$F(z) \bmod 5 = (z^3 + 3z^2 + 2z + 4) \bmod 5 = (z+4)(z^2+4z+1) \bmod 5$$
The period of the sequence modulo $2$ is $2^3-1 = 7$
and the period of the sequence modulo $5$ is $LCM(5^1-1, 5^2-1) = 24$
$2.$ Find the periodicity modulo $2^4$ and modulo $5^4$ (See Theorem $8$)
The period of the sequence modulo $2^4$ is $2^{4-1}.7 = 56$
and the period of the sequence modulo $5^4$ is $5^{4-1}.24 = 3000$
$3.$ Find the periodicity modulo $2^4 5^4$ (See Theorem $10$)
Finally the period of the sequence modulo $2^4 5^4$ is $LCM(56, 3000) = 21000$
The final step is to observe that $$z_{21007} \bmod 10000 = z_{21007 \bmod 21000} \bmod 10000 = z_7 \bmod 10000 = 4637$$
Denote $x_n = \alpha^n+\beta^n+\gamma^n$ and derive a linear recurrence among the $x_n$'s. You can start with $x_1 = 7,$ $x_2 = x_1^2 - 2\sum_{cyc}\alpha\beta = 35$ etc.
– dezdichado Jan 09 '21 at 21:21$$x_{n+3} = 7x_{n+2}-12x_{n+1}+11x_n$$ and you will be interested in finding $x_{21007}\bmod 10000.$ Going further, you need derive some sort of periodicity i.e, find $a$ such that $x_{n+a}\equiv x_n\bmod 10000$
– dezdichado Jan 09 '21 at 22:43