The sequence is defined by the following formula $d_{n + 3} = d_{n + 2} + 2d_{n + 1} - d_n$ where $d_1 = 0, d_2 = 1, d_3 = 2$, $\{0, 1, 2, 4, 7, 13, 23,42, ...\}$ if this sequence is calculated over finite field $p$ $$(d_{n + 3} = d_{n + 2} + 2d_{n + 1} - d_n)\,mod\,\text{p}$$ It follows that if $p$ is prime, then the last three terms $d_{p - 1},\; d_p$, and $d_{p + 1}$ fall within one of the following ending patterns $\;\{4, 2, 1\}$ , $\{p - 1, 0, 1\}$, or $\{p - 6, p - 3, p - 2\}$. this is true for all prime up to tested range, $60000$
my questions
- why only primes follow these patterns?
- is there any non prime(s) following this patterns?
- is there any published work like this and in the same pattern. To see if i can study more about it