Let $p$ and $q$ be prime numbers and $\{a_{n}\}_{n=1}^{\infty}$ be a sequence of integers defined by: \[a_{0}=0, a_{1}=1, a_{n+2}=pa_{n+1}-qa_{n}\quad\forall n\geq 0\]Find $p$ and $q$ if there exists an integer $k$ such that $a_{3k}=-3$.
Problem
Source: 2007 Bulgarian Autumn Math Competition, Problem 12.4
Tags: prime numbers, number theory, linear recurrence
17.11.2024 15:36
Suppose firstly that $p,q\geq 3$. Then $a_2 = p$, $a_3 = p^2-q$, so $a_0$ and $a_3$ are even. Now compute \[ a_{3k+3} = pa_{3k+2} - qa_{3k+1} = (p^2 - q)a_{3k+1} - pqa_{3k}. \]Since \(p^2 - q\) is even, by induction it follows that \(a_{3k}\) is even for every \(k \geq 0\), which contradicts the requirement. Now suppose \(q = 2\). In this case, all the numbers \(a_n\), \(n \geq 2\), are even. Let \(p \geq 3\). We will prove that in this case, \(a_n > 0\) for \(n \geq 1\), which again leads to a contradiction. By induction, we will prove that \(a_{n+1} > a_n > 0\) for \(n \geq 0\). For \(n = 0\), the statement is obvious. Assume that the statement is true for \(n = k\), i.e., \(a_{k+1} > a_k \geq 0\). Then: \[ a_{k+2} = pa_{k+1} - qa_k = (p-2)a_{k+1} + 2(a_{k+1} - a_k) > a_{k+1} > 0, \]and thus \(a_{k+2} > a_{k+1} > 0\). It remains to consider the case where \(p = 2\), \(q > 2\). From the recurrence relation, it follows that, for \(n \geq 0\), we have \(a_{n+2} \equiv 2a_{n+1} \pmod{q}\), and by induction, we conclude that: \[ a_{n} \equiv 2^{n-1} \pmod{q}. \]for all $n\geq 1$. Suppose now that \(a_{3k} = -3\) for some \(k \geq 1\). Then: \[ -3 \equiv a_{3k} \equiv 2^{3k-1} \pmod{q}. \]Now in principle $k$ can be determined mod $q-1$ (or a divisor of it), so this motivates us to work also mod $q-1$. From the recurrence relation, it follows that: $a_{n+2} \equiv 2a_{n+1} - a_n \pmod {q-1}$ and hence by induction $a_n \equiv n \pmod {q-1}$ for all $n\geq 0$. Hence $-3 \equiv a_{3k} \equiv 3k \pmod q-1$, so $2^{3k+3} \equiv 1 \pmod q$ by Fermat's Little Theorem. As $2^{3k-1} \equiv -3 \pmod q$ by above, it follows that $q$ divides $-3 \cdot 16 - 1 = -49$, so $q=7$. \[ a_{n+2} \equiv 2a_{n+1} \equiv \dots \equiv 2^{n+1} \pmod{q-1}, \]and hence: \[ a_{3k} \equiv 2^{3k} - 1 \equiv -3 \pmod{q}. \]By Fermat's Little Theorem, \(2^{q-1} \equiv 1 \pmod{q}\), so \(2^{3k} \equiv -2 \pmod{q}\). From \(2^{3k} - 3 \equiv 0 \pmod{q}\), it follows that \(q \mid 2^{3k} - 3\). This is satisfied if \(q = 7\). Finally, by substituting \(p = 2\) and \(q = 7\) into the recurrence relation, we confirm that $a_3 = -3$. %\(a_{3k} = -3\) for \(k \geq 1\). Therefore, the desired prime numbers are \(p = 2\) and \(q = 7\).