%I #15 Jan 28 2023 11:30:28
%S 2,1093,5,20771,18043,5,20771,18043,5,20771,18043,5,20771,18043,5,
%T 20771,18043,5,20771,18043,5,20771,18043,5,20771,18043,5,20771,18043,
%U 5,20771,18043,5,20771,18043,5,20771,18043,5,20771,18043,5,20771,18043
%N Wieferich sequence where a(1) = 2.
%C Starting with a(3), the sequence is periodic with the following cycle, which is a Wieferich triplet: 5, 20771, 18043.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Wieferich_prime#Wieferich_sequence">Wieferich sequence</a>.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Wieferich_prime">Wieferich prime</a>.
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Wieferich_pair">Wieferich pair</a>.
%o (Python)
%o from sympy import nextprime
%o from gmpy2 import powmod
%o max_n = 45
%o a = 2
%o seq = [a]
%o for i in range(2, max_n+1):
%o p = 2
%o while True:
%o p_squared = p*p
%o if powmod(a, p-1, p_squared) == 1 and (a-1) % p_squared != 0 and (a+1) % p_squared != 0:
%o seq.append(p)
%o a = p
%o break
%o else:
%o p = nextprime(p)
%o print(seq)
%o (PARI) i=0; a=2; print1(a, ", "); while(i<100, forprime(p=2, 10^6, if(Mod(a, p^2)^(p-1)==1 && p%2!=0 && ((a-1) % p^2) && ((a+1) % p^2), print1(p, ", "); i++; a=p; break({n=1})))) \\ _Michel Marcus_, Jan 21 2023
%Y Cf. A178871, A179400, A179678, A244550, A297846.
%K nonn
%O 1,1
%A _Robert C. Lyons_, Jan 19 2023
|