Solving for x in x^2≡65 mod 343
My attention was attracted by this post written by Alon Amit. To be honest, I still don’t fully understand Alon’s solution to the problem: Solving for $x$ in $x^2 ≡ 65\ \hbox{mod}\ 343$. However, I am curious enough and want to double check Alon’s solution; so I wrote the following R code
# reference: https://qr.ae/pF1IOf
is_square <- function(x)
{floor(sqrt(x))^2 == x
}
# test
# (is_square(8))
# (is_square(25))
# (is_square(10000))
# (is_square(1025))
checker <- function(k = 10)
{x <- (1:k) * 343 + 65
re_ <- vapply(x, is_square, FUN.VALUE = logical(1))
re <- which(re_)
output <- sqrt(re * 343 + 65)
output
}
(re <- checker(10000))
## [1] 53 290 396 633 739 976 1082 1319 1425 1662 1768
After seeing the output, I entered these numbers ${53, 290, 396, 633, 739, 976, 1082, 1319, 1425, 1662, 1768}$ into OEIS. I was told this sequence do not match any sequences in OEIS, but a hint was given: “The differences of order 1 appear to be periodic. The next few terms would be 2005, 2111, 2348, 2454.” This is interesting! Next I tried
(diff(re))
## [1] 237 106 237 106 237 106 237 106 237 106
Based on the above I guessed that the positive solutions must be of the form:
$$ a_n = \left\{ \begin{array}{ll} a_{n-1} + 237, & \hbox{if}\ n\ \hbox{is even},\\ a_{n-1} + 106, & \hbox{otherwise,} \end{array} \right. $$
where $n = 2, 3, \ldots, $ and $a_1=53$.Noticing that
$$ 237+106 = 343, $$
I figured out that the positive solutions must be
$$ 53 + 343k,\ \hbox{and}\ 290 + 343k, $$
where $k=0, 1, 2, \ldots.$I also asked AI (MS 365 Copilot), and it correctly gave me the answers (in its solution, it applied Hensel’s lemma).