2007 iTest Problems/Problem 47

Problem

Let $\{X_n\}$ and $\{Y_n\}$ be sequences defined as follows: $X_0=Y_0=X_1=Y_1=1$,

\begin{align*}X_{n+1}&=X_n+2X_{n-1}\qquad(n=1,2,3\ldots),\\ Y_{n+1}&=3Y_n+4Y_{n-1}\qquad(n=1,2,3\ldots).\end{align*}

Let $k$ be the largest integer that satisfies all of the following conditions: $|X_i-k|\leq 2007$, for some positive integer $i$; $|Y_j-k|\leq 2007$, for some positive integer $j$; and $k<10^{2007}$. Find the remainder when $k$ is divided by $2007$.

Solution