I want to determine values of $n$ with $n^4\equiv1 \pmod {25}$, I just assume $n\equiv k \pmod {25}$ and take fourth power on both side for $k=1,..,24$. Is there any faster way?
-
3It’s $25\mid n^4-1=(n^2+1)(n+1)(n-1)$ – J. W. Tanner Oct 14 '24 at 10:37
-
There are modular square root algorithms you can use for larger moduli, but for 25, your brute force method is probably as good as anything. – Simon Goater Oct 14 '24 at 10:59
-
If you’re doing brute force you really need to check only $1$ through $12,$ since $(-1)^4=1$ – J. W. Tanner Oct 14 '24 at 11:03
-
@all thanks for this! – zHzzZ Oct 14 '24 at 11:13
-
1FWIW Calculating modular square roots modulo arbitrary composite integer n is not trivial, but is tractable if you can factorize n. I wrote a program to do it called modnsqrt.c here https://github.com/FastAsChuff/int128-functions-in-c. – Simon Goater Oct 14 '24 at 11:27
-
Do you know Hensel’s lemma? – J. W. Tanner Oct 14 '24 at 12:07
-
1Since the multiplicative group of non-zero integers modulo $25$ is cyclic, once you have found $4$ solutions, you have found them all – J. W. Tanner Oct 14 '24 at 13:21
-
By Hensel (cf. dupes) each root $,x ,\equiv, r \pmod{! 5}$ lifts to a root $$x ,\equiv, r-\dfrac{f(r)}{f'(r)},\equiv, r-\dfrac{r^4-1}{4:!\color{#c00}{r^3}\bmod 5},\equiv, \overbrace{r+(r^4-1)(r \bmod 5)}^{\large 1/\color{#c00}{r^3}\ ,\equiv,\ r\pmod{!5}}\pmod{!5^2}\qquad$$ so the notrivial root $,2,$ lifts to $,2+(2^4-1)(2)\equiv 7\pmod{!25},,$ therefore we conclude that the roots $,\pm1,\pm2\pmod{! 5},$ lift to $,\pm1,\pm7\pmod{!5^2}\ \ $ – Bill Dubuque Oct 14 '24 at 18:53
-
Generally the above shows that the roots of $,x^{p-1}-1\pmod{!p^2},$ are the $p$'th powers of the roots $!\bmod p,$ (put $,f'(r) \equiv -r^{-1}\pmod{!p}$ in Hensel's formula), e.g. here $,2\mapsto 2^5\equiv 7\pmod{!5^2}\ \ $ – Bill Dubuque Oct 14 '24 at 21:15
-
@BillDubuque: doesn't it simply follow from Euler's theorem and the fact $\mathbb Z/p^2\mathbb Z$ is cyclic that $(x^{p})^{p-1}\equiv x^{\phi(p^2)}\equiv1\bmod p^2$? – J. W. Tanner Oct 14 '24 at 21:51
-
@J.W.T Yes of course but that alone is not sufficient (it doesn't prove they are the only roots, i.e. that the roots lifts are unique). – Bill Dubuque Oct 14 '24 at 21:53
-
@BillDubuque: $1^p, 2^p, 3^p,…(p-1)^p$ are certainly distinct mod $p^2$ because they’re distinct mod $p$ (and of course I meant $(\mathbb Z/p^2\mathbb Z)^\times$ in my comment above, but it was too late to edit it) – J. W. Tanner Oct 14 '24 at 22:24
3 Answers
for any $n$ not divisible by $5$ we find $n^4 \equiv 1 \pmod 5.$ Call it $x$ and say it is one of $-2,-1,1,2 \pmod {25}.$ Next, for mod $25$ we take $x + 5 y$ and see what happens. $$ (x + 5y)^4 = x^4 + 20 x^3 y + 150 x^2 y^2 + 600 xy^3 + 625 y^4 $$ $$ (x + 5y)^4 \equiv x^4 + 20 x^3 y \pmod{25}$$ When $x = \pm 1$ we see that $x^4 \equiv 1 \pmod{25}$ and we must take $y \equiv 0 \pmod 5.$ Thus $x \equiv \pm 1 \pmod {25}$
When $x = \pm 2$ we see that $x^4 \equiv 16 \pmod{25}$ and we must have $20 x^3 y \equiv 10 \pmod {25},$ or $4 x^3 y \equiv 2 \pmod {5}.$
When $x=2$ we need $32y \equiv 2 \pmod 5 $ so $y \equiv 1 \pmod 5.$ Thus $x+5y \equiv 7 \pmod {25}.$ In ordinary integers, $7^4 = 2401$
The final value is $-7 \pmod {25}$
This business comes under the name Hensel. For a prime power, we keep raising the exponent of the prime.
- 146,052
Suppose $n^4\equiv1\pmod{25}$. Write $n=5a+b$ with $a,b\in\{0,1,2,3,4\}$. Then $$1=n^4=(5a+b)^4\equiv20ab^3+b^4\pmod{25},$$ which shows that $b^4\equiv1\pmod{5}$ and so $b\neq0\pmod{5}$. Plugging in $b=1,2,3,4$ yields \begin{eqnarray} 1&\equiv&20a\cdot1^3+1^4&\equiv&20a+1\hphantom{1}\pmod{25}\\ 1&\equiv&20a\cdot2^3+2^4&\equiv&10a+16\pmod{25}\\ 1&\equiv&20a\cdot3^3+3^4&\equiv&15a+6\hphantom{1}\pmod{25}\\ 1&\equiv&20a\cdot4^3+4^4&\equiv&\hphantom{1}5a+6\hphantom{1}\pmod{25}, \end{eqnarray} and solving for $a$ yields $a=0,1,3,4$ respectively. This leaves $n=1,7,18,24$ and a quick check shows that these all satisfy $n^4\equiv1\pmod{25}$.
- 67,306
- 8
- 82
- 171
To sum up the comments, there are algorithms for calculating modular square roots, but your brute force method is probably expedient modulo $25$.
A couple of comments on the brute force method. You really need to check only $1$ through $12$, since $(-1)^4=1$, so if $k$ is a solution, then so is $-k\equiv25-k$. And since the multiplicative group of non-zero integers modulo $25 $ is cyclic, once you have found $4$ solutions, you have found them all.
A more direct solution method is to note that $25\mid n^4-1=(n^2+1)(n+1)(n-1)$. Since $5$ dividing more than one of the factors would lead to a contradiction, we have $25\mid n^2+1$ or $n+1$ or $n-1$.
$25\mid n+1\iff n\equiv-1\equiv24\bmod25$.
$25\mid n-1\iff n\equiv 1\bmod25$.
$n^2+1\equiv0\bmod5$ means $n\equiv\pm2\bmod 5$. $n^2+1\equiv0\bmod25 $ could then be solved using Hensel's lemma or simply noting that if $n\equiv2\bmod5$ then $n\equiv 2 $ or $7$ or $12$ or $17$ or $22$ mod $25$, and we see that $7^2+1\equiv0\bmod25.$
Besides $n\equiv7\bmod25$, a solution of $n^2+1\equiv0\bmod25$ is $n\equiv-7\equiv18\bmod25$
Addendum inspired by Bill Dubuque in comments:
For this particular problem, the solutions are $1^5=1$, $2^5=32\equiv7$, $3^5=243\equiv18$, and $4^5=1024\equiv24\bmod25$, since by Euler's theorem if $5\nmid a$ then $a^{\phi(25)}=(a^5)^4\equiv1\bmod25$.
- 63,683
- 4
- 43
- 88