This site is supported by donations to The OEIS Foundation.



(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A001220 Wieferich primes: primes p such that p^2 divides 2^(p-1) - 1. 113
1093, 3511 (list; graph; refs; listen; history; text; internal format)



Sequence is believed to be infinite.

Joseph Silverman showed that the abc-conjecture implies that there are infinitely many primes which are not in the sequence. - Benoit Cloitre, Jan 09 2003

Graves and Murty (2013) improved Silverman's result by showing that for any fixed k > 1, the abc-conjecture implies that there are infinitely many primes == 1 (mod k) which are not in the sequence. - Jonathan Sondow, Jan 21 2013

The squares of these numbers are Fermat pseudoprimes to base 2 (A001567) and Catalan pseudoprimes (A163209). - T. D. Noe, May 22 2003

Primes p that divide the numerator of the harmonic number H((p-1)/2); that is, p divides A001008((p-1)/2). - T. D. Noe, Mar 31 2004

In a 1977 paper, Wells Johnson, citing a suggestion from Lawrence Washington, pointed out the repetitions in the binary representations of the numbers which are one less than the two known Wieferich primes; i.e., 1092 = 10001000100 (base 2); 3510 = 110110110110 (base 2). It is perhaps worth remarking that 1092 = 444 (base 16) and 3510 = 6666 (base 8), so that these numbers are small multiples of repunits in the respective bases. Whether this is mathematically significant does not appear to be known. - John Blythe Dobson, Sep 29 2007

A002326((a(n)^2 - 1)/2) = A002326((a(n)-1)/2). - Vladimir Shevelev, Jul 09 2008, Aug 24 2008

It is believed that p^2 does not divide 3^(p-1) - 1 if p = a(n). This is true for n = 1 and 2. See A178815, A178844, A178900, and Ostafe-Shparlinski (2010) Section 1.1. - Jonathan Sondow, Jun 29 2010

These primes also divide the numerator of the harmonic number H(floor((p-1)/4)). - H. Eskandari (hamid.r.eskandari(AT)gmail.com), Sep 28 2010

1093 and 3511 are prime numbers p satisfying congruence 429327^(p-1) == 1 (mod p^2). Why? - Arkadiusz Wesolowski, Apr 07 2011. Such bases are listed in A247208. - Max Alekseyev, Nov 25 2014

A196202(A049084(a(1)) = A196202(A049084(a(2)) = 1. - Reinhard Zumkeller, Sep 29 2011

If q is prime and q^2 divides a prime-exponent Mersenne number, then q must be a Wieferich prime. Neither of the two known Wieferich primes divide Mersenne numbers. See Will Edgington's Mersenne page in the links below. - Daran Gill, Apr 04 2013

There are no other terms below 4.97*10^17 as established by PrimeGrid (see link below). - Max Alekseyev, Nov 20 2015

Are there other primes q >= p such that q^2 divides 2^(p-1)-1, where p is a prime? - Thomas Ordowski, Nov 22 2014. Any such q must be a Wieferich prime. - Max Alekseyev, Nov 25 2014

Primes p such that p^2 divides 2^r - 1 for some r, 0 < r < p. - Thomas Ordowski, Nov 28 2014, corrected by Max Alekseyev, Nov 28 2014

For some reason, both p=a(1) and p=a(2) also have more bases b with 1<b<p that make b^(p-1)==1 (mod p^2) than any smaller prime p; in other words a(1) and a(2) belong to A248865. - Jeppe Stig Nielsen, Jul 28 2015

Let r_1, r_2, r_3, ...., r_i be the set of roots of the polynomial X^((p-1)/2) - (p-3)! * X^((p-3)/2) - (p-5)! * X^((p-5)/2) - ... - 1. Then p is a Wieferich prime iff p divides sum{k=1, p}(r_k^((p-1)/2)) (see Example 2 in Jakubec, 1994). - Felix Fröhlich, May 27 2016

Arthur Wieferich showed that if p is not a term of this sequence, then the First Case of Fermat's Last Theorem has no solution in x, y and z for prime exponent p (cf. Wieferich, 1909). - Felix Fröhlich, May 27 2016

Let U_n(P, Q) be a Lucas sequence of the first kind, let e be the Legendre symbol (D/p) and let p be a prime not dividing 2QD, where D = P^2 - 4*Q. Then a prime p such that U_(p-e) == 0 (mod p^2) is called a "Lucas-Wieferich prime associated to the pair (P, Q)". Wieferich primes are those Lucas-Wieferich primes that are associated to the pair (3, 2) (cf. McIntosh, Roettger, 2007, p. 2088). - Felix Fröhlich, May 27 2016

Any repeated prime factor of a term of A000215 is a term of this sequence. Thus, if there exist infinitely many Fermat numbers that are not squarefree, then this sequence is infinite, since no two Fermat numbers share a common factor. - Felix Fröhlich, May 27 2016

If the diophantine equation p^x - 2^y = d has more than one solution in positive integers (x, y), with (p, d) not being one of the pairs (3, 1), (3, -5), (3, -13) or (5, -3), then p is a term of this sequence (cf. Scott, Styer, 2004, Corollary to Theorem 2). - Felix Fröhlich, Jun 18 2016

Odd primes p such that Chi_(D_0)(p) != 1 and Lambda_p(Q(sqrt(D_0))) != 1, where D_0 < 0 is the fundamental discriminant of the imaginary quadratic field Q(sqrt(1-p^2)) and Chi and Lambda are Iwasawa invariants (cf. Byeon, 2006, Proposition 1 (i)). - Felix Fröhlich, Jun 25 2016

If q is an odd prime, k, p are primes with p = 2*k+1, k == 3 (mod 4), p == -1 (mod q) and p =/= -1 (mod q^3) (Jakubec, 1998, Corollary 2 gives p == -5 (mod q) and p =/= -5 (mod q^3)) with the multiplicative order of q modulo k = (k-1)/2 and q dividing the class number of the real cyclotomic field Q(Zeta_p + (Zeta_p)^(-1)), then q is a term of this sequence (cf. Jakubec, 1995, Theorem 1). - Felix Fröhlich, Jun 25 2016

From Felix Fröhlich, Aug 06 2016: (Start)

Primes p such that p-1 is in A240719.

Prime terms of A077816 (cf. Agoh, Dilcher, Skula, 1997, Corollary 5.9).

p = prime(n) is in the sequence iff T(2, n) > 1, where T = A258045.

p = prime(n) is in the sequence iff an integer k exists such that T(n, k) = 2, where T = A258787. (End)


R. Crandall and C. Pomerance, Prime Numbers: A Computational Perspective, Springer, NY, 2001; see p. 28.

R. K. Guy, Unsolved Problems in Number Theory, A3.

G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers, 5th ed., Oxford Univ. Press, 1979, th. 91.

Y. Hellegouarch, "Invitation aux mathématiques de Fermat Wiles", Dunod, 2eme Edition, pp. 340-341.

Pace Nielsen, Wieferich primes, heuristics, computations, Abstracts Amer. Math. Soc., 33 (#1, 20912), #1077-11-48.

P. Ribenboim, The Book of Prime Number Records. Springer-Verlag, NY, 2nd ed., 1989, p. 263.

D. Wells, The Penguin Dictionary of Curious and Interesting Numbers. Penguin Books, NY, 1986, 163.


Table of n, a(n) for n=1..2.

T. Agoh, K. Dilcher, L. Skula, Fermat Quotients for Composite Moduli, Journal of Number Theory 66(1), 1997, 29-50.

Joerg Arndt, Matters Computational (The Fxtbook), p.780

D. Byeon, Class numbers, Iwasawa invariants and modular forms, Trends in Mathematics, Vol. 9, No. 1, (2006), 25-29.

C. K. Caldwell, The Prime Glossary, Wieferich prime

C. K. Caldwell, Prime-square Mersenne divisors are Wieferich

D. X. Charles, On Wieferich Primes

R. Crandall, K. Dilcher and C. Pomerance, A search for Wieferich and Wilson primes, Mathematics of Computation, Volume 66, 1997.

J. K. Crump, Joe's Number Theory Web, Weiferich Primes (sic)

John Blythe Dobson, A note on the two known Wieferich Primes

F. G. Dorais, WPSE - A Wieferich Prime Search Engine (A program to search Wieferich primes written by F. G. Dorais.) - Felix Fröhlich, Jul 13 2014

F. G. Dorais and D. W. Klyve, A Wieferich Prime Search up to 6.7*10^15, Journal of Integer Sequences, Vol. 14, 2011.

Will Edgington, Mersenne Page.

A. Granville, K. Soundararajan, A binary additive problem of Erdos and the order of 2 mod p^2, Raman. J. 2 (1998) 283-298

Hester Graves and M. Ram Murty, The abc conjecture and non-Wieferich primes in arithmetic progressions, Journal of Number Theory, 133 (2013), 1809-1813.

Lorenz Halbeisen and Norbert Hungerbuehler, Number theoretic aspects of a combinatorial function, Notes on Number Theory and Discrete Mathematics 5 (1999) 138-150. (ps, pdf)

S. Jakubec, Connection between the Wieferich congruence and divisibility of h+, Acta Arithmetica, Vol. 71, No. 1 (1995), 55-64.

S. Jakubec, On divisibility of the class number h+ of the real cyclotomic fields of prime degree l, Mathematics of Computation, Vol. 67, No. 221 (1998), 369-398.

S. Jakubec, The Congruence for Gauss Period, Journal of Number Theory, Vol. 48, No. 1 (1994), 36-45.

W. Johnson, On the nonvanishing of Fermat quotients (mod p), Journal f. die Reine und Angewandte Mathematik 292 (1977): 196-200.

J. Knauer and J. Richstein, The continuing search for Wieferich primes, Math. Comp., 75 (2005), 1559-1563.

D. H. Lehmer, On Fermat's quotient, base two, Math. Comp. 36 (1981), 289-290.

P. Lezak, Software for searching Wieferich primes - Felix Fröhlich, Jul 13 2014

R. J. McIntosh and E. L. Roettger, A search for Fibonacci-Wieferich and Wolstenholme primes, Math. Comp. vol 76, no 260 (2007) pp 2087-2094.

C. McLeman, PlanetMath.org, Wieferich prime

Sihem Mesnager and Jean-Pierre Flori, A note on hyper-bent functions via Dillon-like exponents

A. Ostafe and I. Shparlinski, Pseudorandomness and Dynamics of Fermat Quotients, arXiv:1001.1504 [math.NT], 2010.

Christian Perfect, Integer sequence reviews on Numberphile (or vice versa), 2013.

M. Rodenkirch, PRPNet (The PRPNet package includes wwww, a program that can search for Wieferich and Wall-Sun-Sun primes.) - Felix Fröhlich, Jul 13 2014

R. Scott and R. Styer, On p^x - q^y = c and related three term exponential Diophantine equations with prime bases, Journal of Number Theory, Vol. 105, No. 2 (2004), 212-234.

J. Silverman, Wieferich's Criterion and the abc Conjecture, J. Number Th. 30 (1988) 226-237.

J. Sondow, Lerch quotients, Lerch primes, Fermat-Wilson quotients, and the Wieferich-non-Wilson primes 2, 3, 14771, arXiv 2011.

J. Sondow, Lerch Quotients, Lerch Primes, Fermat-Wilson Quotients, and the Wieferich-non-Wilson Primes 2, 3, 14771, Combinatorial and Additive Number Theory, CANT 2011 and 2012, Springer Proc. in Math. & Stat., vol. 101 (2014), pp. 243-255.

PrimeGrid, Wieferich Prime Search statistics

V. Shevelev, Overpseudoprimes, Mersenne Numbers and Wieferich Primes, arXiv:0806.3412 [math.NT], 2008.

Michel Waldschmidt, Lecture on the abc conjecture and some of its consequences, Abdus Salam School of Mathematical Sciences (ASSMS), Lahore, 6th World Conference on 21st Century Mathematics 2013.

Michel Waldschmidt, Lecture on the abc conjecture and some of its consequences, Abdus Salam School of Mathematical Sciences (ASSMS), Lahore, 6th World Conference on 21st Century Mathematics 2013.

Eric Weisstein's World of Mathematics, Wieferich Prime

Eric Weisstein's World of Mathematics, abc Conjecture

Eric Weisstein's World of Mathematics, Integer Sequence Primes

Wieferich Home Page, Search for Wieferich primes

A. Wieferich, Zum letzten Fermat'schen Theorem, Journal für die reine und angewandte Mathematik, 136 (1909), 293-302.

Wikipedia, Wieferich prime

P. Zimmermann, Records for Prime Numbers


A178815(A000720(p))^(p-1) - 1 mod p^2 = A178900(n), where p = a(n). - Jonathan Sondow, Jun 29 2010

Odd primes p such that A002326((p^2-1)/2) = A002326((p-1)/2). See A182297. - Thomas Ordowski, Feb 04 2014


wieferich := proc (n) local nsq, remain, bin, char: if (not isprime(n)) then RETURN("not prime") fi: nsq := n^2: remain := 2: bin := convert(convert(n-1, binary), string): remain := (remain * 2) mod nsq: bin := substring(bin, 2..length(bin)): while (length(bin) > 1) do: char := substring(bin, 1..1): if char = "1" then remain := (remain * 2) mod nsq fi: remain := (remain^2) mod nsq: bin := substring(bin, 2..length(bin)): od: if (bin = "1") then remain := (remain * 2) mod nsq fi: if remain = 1 then RETURN ("Wieferich prime") fi: RETURN ("non-Wieferich prime"): end: # Ulrich Schimke (ulrschimke(AT)aol.com), Nov 01 2001


Select[Prime[Range[50000]], Divisible[2^(#-1)-1, #^2]&]  (* Harvey P. Dale, Apr 23 2011 *)

Select[Prime[Range[50000]], PowerMod[2, #-1, #^2]==1&] (* Harvey P. Dale, May 25 2016 *)



import Data.List (elemIndices)

a001220 n = a001220_list !! (n-1)

a001220_list = map (a000040 . (+ 1)) $ elemIndices 1 a196202_list

-- Reinhard Zumkeller, Sep 29 2011


N=10^9; default(primelimit, N);

forprime(n=2, N, if(Mod(2, n^2)^(n-1)==1, print1(n, ", ")));

\\ Joerg Arndt, May 01 2013


from sympy import prime

from gmpy2 import powmod

A001220_list = [p for p in (prime(n) for n in range(1, 10**7)) if powmod(2, p-1, p*p) == 1]

# Chai Wah Wu, Dec 03 2014


See A007540 for a similar problem.

Sequences "primes p such that p^2 divides X^(p-1)-1": A014127 (X=3), A123692 (X=5), A212583 (X=6), A123693 (X=7), A045616 (X=10).

Cf. A001567, A002323, A077816, A001008, A039951, A049094, A126196, A126197, A178815, A178844, A178871, A178900, A246503.

Sequence in context: A038469 A246503 A077816 * A265630 A270833 A273471

Adjacent sequences:  A001217 A001218 A001219 * A001221 A001222 A001223




N. J. A. Sloane



Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy .

Last modified October 27 14:46 EDT 2016. Contains 277181 sequences.