Find the least odd prime factor of $155^8+1$. How do I do this without using Wolfram Alpha or something?
Asked
Active
Viewed 221 times
1
-
1Indeed the least odd prime factor can't be a multiple of $5$, since (proper) multiples of $5$ aren't primes – the only multiple of $5$ that's a prime is $5$. – joriki Feb 09 '20 at 18:25
2 Answers
4
$155^8\equiv-1\pmod p$ means $155^{16}\equiv1\pmod p.$
We know $155^{p-1}\equiv1\pmod p$.
That means $16|p-1$,
so candidates for $p$ are $17$, $97$, $\color{red}{113}$, ...

J. W. Tanner
- 60,406
-
It's true that $16\mid p-1$, but this doesn't follow from $155^{p-1}\equiv1\pmod p$. Rather, both of these facts follow from the fact that $p-1$ is the order of the multiplicative group $\bmod p$. – joriki Feb 09 '20 at 18:28
-
@joriki: thank you for your thoughts. Couldn't I argue that $155^{16}\equiv155^{p-1}\equiv1\implies155^{\gcd(16,p-1)}\equiv1$ and if $\gcd(16,p-1)<16$ then we'd have $155^8\equiv1$? – J. W. Tanner Feb 09 '20 at 18:36
-
2Interesting. Yes, you could argue that. I'm not sure everyone will read that into the "That means" in the answer (I didn't), but that would certainly be a valid argument that does without mentioning the entire multiplicative group. – joriki Feb 09 '20 at 19:42
-
Do you get $155^{16}\equiv155^{p-1}\equiv1\implies155^{\gcd(16,p-1)}\equiv1$ by using the theory $\quad$ Prove that $\gcd(a^n - 1, a^m - 1) = a^{\gcd(n, m)} - 1$ $;$? – CopyPasteIt Feb 12 '20 at 16:38
-
0
Following is a Python program that uses the Tonelli-Shanks algorithm;
the code for the algorithm is here at codereview.stackexchange.com.
The output lines
print(p, alg_list_prime_mod_sqrt_of_minus_one, res)
shows for each prime $p$ a list of solutions to $x^2 \equiv -1 \pmod p$ while $\text{res } \equiv {155}^4 \pmod p$.
When $\text{res}$ is a square root of $-1$ $\text{modulo-}p$ and in the list the program terminates.
Python program:
from math import sqrt; from itertools import count, islice
def isPrime(n):
return n > 1 and all(n%i for i in islice(count(2), int(sqrt(n)-1)))
def legendre_symbol(a, p):
"""
Legendre symbol
Define if a is a quadratic residue modulo odd prime
http://en.wikipedia.org/wiki/Legendre_symbol
"""
ls = pow(a, (p - 1)//2, p)
if ls == p - 1:
return -1
return ls
def prime_mod_sqrt(a, p):
"""
Square root modulo prime number
Solve the equation
x^2 = a mod p
and return list of x solution
http://en.wikipedia.org/wiki/Tonelli-Shanks_algorithm
"""
a %= p
# Simple case
if a == 0:
return [0]
if p == 2:
return [a]
# Check solution existence on odd prime
if legendre_symbol(a, p) != 1:
return []
# Simple case
if p % 4 == 3:
x = pow(a, (p + 1)//4, p)
return [x, p-x]
# Factor p-1 on the form q * 2^s (with Q odd)
q, s = p - 1, 0
while q % 2 == 0:
s += 1
q //= 2
# Select a z which is a quadratic non resudue modulo p
z = 1
while legendre_symbol(z, p) != -1:
z += 1
c = pow(z, q, p)
# Search for a solution
x = pow(a, (q + 1)//2, p)
t = pow(a, q, p)
m = s
while t != 1:
# Find the lowest i such that t^(2^i) = 1
i, e = 0, 2
for i in range(1, m):
if pow(t, e, p) == 1:
break
e *= 2
# Update next value to iterate
b = pow(c, 2**(m - i - 1), p)
x = (x * b) % p
t = (t * b * b) % p
c = (b * b) % p
m = i
return [x, p-x]
for p in range(2,555):
if isPrime(p):
mult = (155 % p)
res = 1
for dum in range(0,4):
res = (res * mult) % p
alg_list_prime_mod_sqrt_of_minus_one = prime_mod_sqrt(-1, p)
print(p, alg_list_prime_mod_sqrt_of_minus_one, res)
if res in alg_list_prime_mod_sqrt_of_minus_one:
if p % 2 == 1:
print('The number', p , 'is the smallest odd prime factor for 155^4 + 1.')
break
$\text{*** OUTPUT ***}$
2 [1] 1
3 [] 1
5 [3, 2] 0
7 [] 1
11 [] 1
13 [8, 5] 1
17 [4, 13] 16
19 [] 5
23 [] 8
29 [12, 17] 24
31 [] 0
37 [6, 31] 33
41 [32, 9] 1
43 [] 15
47 [] 17
53 [23, 30] 44
59 [] 26
61 [11, 50] 20
67 [] 47
71 [] 19
73 [46, 27] 64
79 [] 2
83 [] 33
89 [34, 55] 25
97 [22, 75] 88
101 [91, 10] 68
103 [] 58
107 [] 39
109 [33, 76] 63
113 [98, 15] 15
The number 113 is the smallest odd prime factor for 155^4 + 1.

CopyPasteIt
- 11,366