# Wieferich pair

In mathematics, a Wieferich pair is a pair of prime numbers p and q that satisfy
    p$^{q−1}$ ≡ 1 (mod q$^2$) and q$^{p−1}$ ≡ 1 (mod p$^2$)
Wieferich pairs are named after German mathematician Arthur Wieferich. Wieferich pairs play an important role in Preda Mihăilescu's 2002 proof of Mihăilescu's theorem (formerly known as Catalan's conjecture).

## Known Wieferich pairs

There are only 7 Wieferich pairs known:
    (2, 1093), (3, 1006003), (5, 1645333507), (5, 188748146801), (83, 4871), (911, 318917), and (2903, 18787). (sequence OEIS: A124121 and OEIS: A124122 in OEIS)

## Wieferich triple

A Wieferich triple is a triple of prime numbers p, q and r that satisfy
    p$^{q−1}$ ≡ 1 (mod q$^2$), q$^{r−1}$ ≡ 1 (mod r$^2$), and r$^{p−1}$ ≡ 1 (mod p$^2$).
There are 17 known Wieferich triples:
    (2, 1093, 5), (2, 3511, 73), (3, 11, 71), (3, 1006003, 3188089), (5, 20771, 18043), (5, 20771, 950507), (5, 53471161, 193), (5, 6692367337, 1601), (5, 6692367337, 1699), (5, 188748146801, 8807), (13, 863, 23), (17, 478225523351, 2311), (41, 138200401, 2953), (83, 13691, 821), (199, 1843757, 2251), (431, 2393, 54787), and (1657, 2281, 1667). (sequences OEIS: A253683, OEIS: A253684 and OEIS: A253685 in OEIS)

## Barker sequence

Barker sequence or Wieferich n-tuple is a generalization of Wieferich pair and Wieferich triple. It is primes (p$_1$, p$_2$, p$_3$, ..., p$_n$) such that
    p$_1$$^{p2−1}$ ≡ 1 (mod p$_2$$^2$), p$_2$$^{p3−1}$ ≡ 1 (mod p$_3$$^2$), p$_3$$^{p4−1}$ ≡ 1 (mod p$_4$$^2$), ..., p$_{n−1}$$^{pn−1}$ ≡ 1 (mod p$_n$$^2$), p$_n$$^{p1−1}$ ≡ 1 (mod p$_1$$^2$).
For example, (3, 11, 71, 331, 359) is a Barker sequence, or a Wieferich 5-tuple; (5, 188748146801, 453029, 53, 97, 76704103313, 4794006457, 12197, 3049, 41) is a Barker sequence, or a Wieferich 10-tuple.
For the smallest Wieferich n-tuple, see OEIS: A271100, for the ordered set of all Wieferich tuples, see OEIS: A317721.

## Wieferich sequence

Wieferich sequence is a special type of Barker sequence. Every integer k>1 has its own Wieferich sequence. To make a Wieferich sequence of an integer k>1, start with a(1)=k, a(n) = the smallest prime p such that a(n-1)$^{p-1}$ = 1 (mod p) but a(n-1) ≠ 1 or -1 (mod p). It is a conjecture that every integer k>1 has a periodic Wieferich sequence. For example, the Wieferich sequence of 2:
    2, 1093, 5, 20771, 18043, 5, 20771, 18043, 5, ..., it gets a cycle: {5, 20771, 18043}. (a Wieferich triple)
The Wieferich sequence of 83:
    83, 4871, 83, 4871, 83, 4871, 83, ..., it gets a cycle: {83, 4871}. (a Wieferich pair)
The Wieferich sequence of 59: (this sequence needs more terms to be periodic)
    59, 2777, 133287067, 13, 863, 7, 5, 20771, 18043, 5, ... it also gets 5.
However, there are many values of a(1) with unknown status. For example, the Wieferich sequence of 3:
    3, 11, 71, 47, ? (There are no known Wieferich primes in base 47).
The Wieferich sequence of 14:
    14, 29, ? (There are no known Wieferich primes in base 29 except 2, but 2$^2$ = 4 divides 29 - 1 = 28)
The Wieferich sequence of 39:
    39, 8039, 617, 101, 1050139, 29, ? (It also gets 29)
It is unknown that values for k exist such that the Wieferich sequence of k does not become periodic. Eventually, it is unknown that values for k exist such that the Wieferich sequence of k is finite.
When a(n - 1)=k, a(n) will be (start with k = 2): 1093, 11, 1093, 20771, 66161, 5, 1093, 11, 487, 71, 2693, 863, 29, 29131, 1093, 46021, 5, 7, 281, ?, 13, 13, 25633, 20771, 71, 11, 19, ?, 7, 7, 5, 233, 46145917691, 1613, 66161, 77867, 17, 8039, 11, 29, 23, 5, 229, 1283, 829, ?, 257, 491531, ?, ... (For k = 21, 29, 47, 50, even the next value is unknown)