$D$ is a positive integer that is not a perfect square
Recently I am taking a introductory number theory course and I met this question right after we learned Pell's equation and Diophantine Approximation. However, I can't see a connection between those 2 topics and this question.
I was trying to assume that $ y = 41k$ where k is an positive integer and substitute it into the equation and I hoped eventually this will simplify to an equation that conforms the form of the Pell's equation which is $x^2-Dy^2=1$. However I did not get any from there.
Also I tried to approach this problem from the Pell's Equation Theorem. Then I found it is impossible to get anything useful from expanding $(x+y{\sqrt D})^k$ plus I cannot determine the smallest solution for it because I don't know the value of D.
Could someone help me on this question? Thank you!
Best Answer
Let $x_n+y_n\sqrt D=(x_1+y_1\sqrt D)^n$ the $n^{\text{th}}$ power of the primitive unit. Since there are only $41^2=1681$ possibilities for $(x_n,y_n)$ $\pmod{41}$ a duplicate must be encountered at some point: $x_n\equiv x_m\pmod{41}$ and $y_n\equiv y_m\pmod{41}$ for some $n>m\ge1$. Then $x_{n-m}=x_nx_m-Dy_ny_m\equiv x_n^2-Dy_n^2\equiv1\pmod{41}$ and $y_{n-m}=-x_ny_m+y_nx_m\equiv-x_ny_n+y_nx_n\equiv0\pmod{41}$.
EDIT: As an example let $D=3$ and the first solution to Pell's equation is $x_1+y_1\sqrt D=2+1\sqrt3$. Now let's make a table of values $\pmod{41}$: $$\begin{array}{r|r|r}n&x_n&y_n\\\hline 1&2&1\\ 2&7&4\\ 3&26&15\\ 4&15&15\\ 5&34&4\\ 6&39&1\\ 7&40&0\\ 8&39&40\\ 9&34&37\\ 10&15&26\\ 11&26&26\\ 12&7&37\\ 13&2&40\\ 14&1&0\\ 15&2&1\end{array}$$ For example $(2+1\sqrt3)^2=7+4\sqrt3$, $(2+1\sqrt3)^3=26+15\sqrt3$, and $(2+1\sqrt3)^4=97+56\sqrt3$ so $x_4=97\equiv15\pmod{41}$ and $y_4=56\equiv15\pmod{41}$, thus explaining the row $n=4$, $x_n\equiv15$, $y_n\equiv15$. The first duplicate was $x_{15}\equiv x_1\equiv2\pmod{41}$ and $y_{15}\equiv y_1\equiv1\pmod{41}$, so that tells us that $x_{15-1}=x_{14}\equiv1\pmod{41}$ and $y_{15-1}=y_{14}\equiv0\pmod{41}$. Perhaps a bit anticlimactic since we already found $2$ solutions on our way to generating the first duplicate. Indeed $x_{14}^2-3y_{14}^2=50843527^2-3\cdot29354524^2=1$ and $y_{14}=29354524=41\cdot715964$.
EDIT: Oh yeah, the last $2$ lines: since $(x_n+y_n\sqrt D)(x_n-y_n\sqrt D)=(x_1+y_1\sqrt D)^n(x_1-y_1\sqrt D)^n=(x_1^2-Dy_1^2)^n=(1)^n=1$ we see that $(x_n+y_n\sqrt D)^{-1}=(x_n-y_n\sqrt D)$ so $(x_{n-m}+y_{n-m}\sqrt D)=(x_n+y_n\sqrt D)(x_m-y_m\sqrt D)=(x_nx_m-Dy_ny_m)+(-x_ny_m+y_nx_m)\sqrt D$
EDIT My program that finds the fundamental solution to $x^2-Dy^2=1$ and the first power $n-m$ for which $x_{n-m}\equiv1\pmod{41}$ and $y_{n-m}\equiv0\pmod{41}$
And its output: