The Bernoulli number page

This page gives an introduction to the Bernoulli numbers and polynomials, as well as to the Euler numbers. Besides some basic results, one also finds some special and advanced properties.

For the computation of the Bernoulli numbers up to the huge index 107 see the program CalcBn V3.0 below. For further reading see the list of books at the end. See here for News & History.

Bernoulli numbers


The Bernoulli numbers Bn play an important role in several topics of mathematics. These numbers can be defined by the power series


where all numbers Bn are zero with odd index n > 1. The even-indexed rational numbers Bn alternate in sign. First values are


The values can be computed iteratively by the recurrence formula


which can be written symbolically as


The sequences of the numerators and denominators of Bn are A027641 and A027642, respectively.

Sum of consecutive integer powers

Jacob Bernoulli Bernoulli1713 (1655-1705) introduced a sequence of rational numbers in his Ars Conjectandi, which was published posthumously in 1713. He used these numbers, later called Bernoulli numbers, to compute the sum of consecutive integer powers.

This formula is given by


where Sn(x) is a polynomial of degree n + 1.

Explicit formulas

An explicit formula for Bn was derived by Worpitzky Worpitzky1883 in 1883:


using the symbol


with S2(n, k) being the Stirling numbers of the second kind.

He also gave another formula for Sn(x):


Furthermore, one has by means of iterated forward differences the relation


yielding the double sum


Special values of the Riemann zeta function

The Bernoulli numbers are connected with the Riemann zeta function


on the positive real axis by Euler's celebrated formula for positive even n, also valid for n = 0:


The functional equation of ζ(s) leads to the following formula for negative integer arguments:


Regular and irregular primes

In 1850 Kummer Kummer1850 introduced two classes of odd primes, later called regular and irregular (see, e.g., Hilbert Hilbert1897;Chap.~31).

An odd prime p is called regular if p does not divide the class number of the cyclotomic field chqmup where cmup is the set of p-th roots of unity; otherwise irregular. Kummer then proved that Fermat's Last Theorem is true, that is


has no solution in positive integers x, y, and z, for the case when the exponent n is a regular prime.

He also provided an equivalent definition concerning Bernoulli numbers:

If p does not divide any of the numerators of the Bernoulli numbers B2, B4, , Bp3, then p is regular.

The irregular primes below 100 are 37, 59, and 67; see A000928.

In 1915 Jensen Jensen1915 proved that infinitely many irregular primes p exist with the restriction p3 (mod 4). Carlitz Carlitz1954 later gave a short (and weaker) proof without any restriction on p.

Unfortunately, it is still an open question whether infinitely many regular primes exist. However, several computations (see, e.g., Hart, Harvey, and Ong HartHarveyOng2017) suggest that about 60% of all primes are regular, which agree with an expected distribution proposed by Siegel Siegel1964.

Irregular pairs

The pair (p, ) is called an irregular pair, if p divides the numerator of B where is even and 2 ≤ p − 3.

The index of irregularity i(p) is defined to be the number of such pairs belonging to p. If i(p) = 0, then p is regular, otherwise irregular.

The first irregular pairs are (37, 32), (59, 44), and (67, 58). The irregular prime p = 157 is the least prime with i(p) = 2: (157, 62), (157, 110).

Structure of the denominator

The denominator of Bn for positive even n is given by the famous von Staudt-Clausen theorem, independently found by von Staudt Staudt1840 and Clausen Clausen1840 in 1840:


As a consequence, the denominator is squarefree and divisible by 6.

Given a Bernoulli number Bn with n even, Rado Rado1934 showed that there exist infinitely many even m such that


implying that the numbers Bm have the same denominator as Bn.

A special case is given for n = 2p, where p is an odd prime p1 (mod 3):


See A112772, which is a subsequence of A051222; the sequence of the increasing denominators is A090801.

Structure of the numerator

The unsigned numerator of the divided Bernoulli number Bn/n for positive even n equals 1 only for n = 2, 4, 6, 8, 10, 14; otherwise the numerator consists of a product of powers of irregular primes:


Since Bn/n is a p-integer for all primes p with p − 1 not dividing n, the structure of the numerator of Bn is given by


The additional left product is a trivial factor of Bn that divides n, see A300711.

For the signed numerators of Bn and Bn/n for even n see A000367 and A001067, respectively.

Kummer congruences

The Kummer congruences describe the most important arithmetical properties of the Bernoulli numbers, which give a modular relation between these numbers.

Let φ denote Euler's totient function. Let n and m be positive even integers and p be a prime with p − 1 ∤ n.

If nm (mod φ(pr)) where r ≥ 1, then




In 1851 Kummer Kummer1851 originally introduced these congruences without the Euler factors (1 − pn1) and hence with restrictions on r and n. He showed that the second congruence holds for n > r, whereas the first congruence was derived from the latter only for r = 1 (in these cases the Euler factors vanish). Subsequently, these congruences were widely generalized by several authors (see, e.g., Fresnel Fresnel1967).

Constructing p-adic zeta functions

The values ζ(1 − n) = −Bn/n and the Kummer congruences lead to the construction of p-adic zeta and L-functions, as introduced by Kubota and Leopoldt KubotaLeopoldt1964 in 1964. One kind of their constructions deals with p-adic zeta functions defined in certain residue classes; for a detailed theory see Koblitz Koblitz1996;Chap. II.

For a prime p and even n ≥ 2 define the zeta function


Let p ≥ 5 and  ∈ {2, 4, , p − 3} be fixed. Define the p-adic zeta function on chzp by


for p-adic integers s by taking any sequence (tν)ν1 of nonnegative integers that p-adically converges to s. Indeed, this function is well-defined and has the following properties.

At nonnegative integer arguments the function ζ(p,)(s) interpolates values of the function ζp(1 − n). The Kummer congruences then state for r1 that


when ss' (mod pr1) for nonnegative integers s and s'.

Since is dense in p, the function ζ(p,)(s), restricted on nonnegative integer arguments, uniquely extends, by means of the Kummer congruences and preserving the interpolation property, to a continuous function on p.

Zeros of p-adic zeta functions

The p-adic zeta function ζ(p,)(s) can be written as a special Mahler expansion (Kellner Kellner2007):


with integral coefficients


One has the relation


Condition for the existence of a unique simple zero (Kellner Kellner2007):

If (p, ) is an irregular pair and a1chzpu, that is


then the p-adic zeta function ζ(p,)(s) has a unique simple zero ξ(p,)chzp.

So far, no irregular pair (p, ) has been found that the non congruence relation above holds as a congruence.

Example: In the case (p, ) = (37, 32) one computes that


For more p-adic digits see Kellner Kellner2007 and A299468.

Irregular pairs of higher order

The irregular pairs of higher order describe the first appearance of higher powers of irregular prime factors of Bn/n.

An irregular pair (p, n) of order r has the property that pr divides Bn/n with n < φ(pr) = (p − 1)pr1. For r = 1 this gives the usual definition of irregular pairs, since the condition p divides Bn/n is then equal to p divides Bn.

A zero of the p-adic zeta function ζ(p,)(s) describes the irregular pairs (p, n) of higher order with n (mod p − 1), and vice versa (Kellner Kellner2007).

For example, one obtains for the irregular pair (37, 32) that




Irregular pairs of higher order can be effectively and easily computed using Bernoulli numbers with small indices. By this means one can even predict the extremely huge index of the first occurrence of the power 3737 as listed above; see A251782.

Conjecture on the structure of the Bernoulli numbers

Under the assumption that every p-adic zeta function ζ(p,)(s) has a unique simple zero ξ(p,) in case (p, ) is an irregular pair, one has for even n2 (Kellner Kellner2007):




and |·|p is the ultrametric p-adic absolute value.

The denominator can be described by poles (always lying at ξ(p,0) = 0) and the numerator by zeros of p-adic zeta functions. Equivalently, the formula reads for the Bernoulli numbers:


The first product gives the trivial factor, the second product describes the product over irregular prime powers, and the third product yields the denominator of Bn.

Moreover, the formulas are valid for all irregular pairs (p, ) with


This follows by computations of irregular pairs and cyclotomic invariants in that range by Hart, Harvey, and Ong HartHarveyOng2017. So far, no counterexample is known.

Class numbers of imaginary quadratic fields

Let h(d) denote the class number of the imaginary quadratic field Q(√d) of discriminant d < −4. There is the following connection with the Bernoulli numbers due to Carlitz Carlitz1953.

If p > 3 is a prime with p3 (mod 4), then


using the well-known relation that h(−p) < p. This implies that p cannot divide the above Bernoulli number. Therefore, an irregular pair (p, (p + 1)/2) cannot exist when p3 (mod 4).

Asymptotic formulas

The Minkowski-Siegel mass formula states for positive integers n = 2k with 8 ∣ n that


where the sum runs over all even unimodular lattices Λ in dimension n and Aut(Λ) is the automorphism group of Λ.

The products of (divided) Bernoulli numbers with explicit asymptotic constants (Kellner Kellner2009) are given by




where 𝒜 is the Glaisher-Kinkelin constant A074962 and 𝒵 is the product over all Riemann zeta values at even positive integer arguments A080729.

Bernoulli polynomials


The Bernoulli polynomials Bn(x) can be defined by the generating function


and are given by the formula


which can be written symbolically as


The constant term of these polynomials is the Bernoulli number


Sum of consecutive integer powers

The polynomial Sn(x) of degree n + 1, giving the sum of the nth powers of consecutive integers from 1 up to x − 1 in case x is a positive integer, satisfies the relation


Denominators of the Bernoulli polynomials

The denominator of Bn(x) − Bn, the nth Bernoulli polynomial without constant term, is given by the remarkable formula (Kellner and Sondow KellnerSondow2017a, Kellner Kellner2017a, and A195441)


where sp(n) denotes the sum of the base-p digits of n. The finite product can be written with explicit sharp bounds as




If {·} denotes the fractional part and n1 is a fixed integer, then there is the surprising relation (Kellner Kellner2017b):


The denominator of the nth Bernoulli polynomial Bn(x) can be described by a similar formula (Kellner and Sondow KellnerSondow2017b, A144845):


Quotients of the denominators

Further properties are given by Kellner and Sondow KellnerSondow2017b. Using the notation


we have the relations




This implies a sequence of divisibilities


Furthermore, the denominators obey the rules


As a consequence, the quotients


are integral for odd and even n (A286516 and A286517), respectively.

Euler numbers


The Euler numbers En may be defined by the power series of the hyperbolic secant function


which is an even function implying that all En = 0 with odd index n. The even-indexed numbers En are integers and alternate in sign. The first values (A028296) are


The values can be computed iteratively for even n2 by the recurrence formula


which can be written symbolically as


E-irregular primes and pairs

A prime p is called E-irregular, if p divides at least one of the Euler numbers E2,  E4, , Ep3; otherwise p is E-regular.

The pair (p, ) is called an E-irregular pair, if p divides E where is even and 2p − 3. The index of E-irregularity iE(p) is defined to be the number of such pairs belonging to p.

The first E-irregular pairs are (19, 10), (31, 22), and (43, 12); see A120337. The E-irregular prime p = 241 is the least prime with iE(p) = 2: (241, 210), (241, 238).

In 1954 Carlitz Carlitz1954 proved that infinitely many E-irregular primes exist. Later Ernvall Ernvall1975 showed the more specialized result that infinitely many E-irregular primes p ≢ ±1 (mod 8) exist.

As in the case of the Bernoulli numbers, it is still an open question whether infinitely many E-regular primes exist.

Conjecture on the structure of the Euler numbers

For the Euler numbers one can state a similar conjectural formula as in the case of the Bernoulli numbers, though it is a bit more complicated.

One may conjecturally state for even n2 that


where ξ(p,) is the unique simple zero of a certain p-adic L-function associated with an E-irregular pair (p, ) ∈ cpsieirr when 0, respectively, with a rare exceptional prime p with (p, 0) ∈ cpsieexc in case = 0.

Class numbers of imaginary quadratic fields

Let h(d) denote the class number of the imaginary quadratic field Q(√d) of discriminant d < −4. Due to Carlitz Carlitz1953 one has the following connection with the Euler numbers.

If p is a prime with p1 (mod 4), then


using the well-known relation h(−4p) < p. Therefore p cannot divide the above Euler number. Consequently, an E-irregular pair (p, (p − 1)/2) cannot exist when p1 (mod 4).


Program CalcBn V3.0 - a multi-threaded program for computing the Bernoulli numbers

CalcBn V3.0 is a multi-threaded program for computing the Bernoulli numbers via the Riemann zeta function. It uses special optimizations such that the main part of calculation can be performed by integer arithmetic. CalcBn depends on the GMP library, so it is recommended to use the latest version of GMP with possible optimizations for the current hardware. The source code of CalcBn for 32/64-bit Linux and Windows complies with C++11. It is released under the terms of the GNU Public License.



Program for Windows
 V3.0, Build 20180315, GCC 7.3.0, GMP 6.1.2
Source code for Linux / Windows

Options of program

Usage: CalcBn [option] index
  -v, --version   version and copyright
  -t, --thread n  use n (1..32) threads
  -s, --suppress  no output of result
  -d, --digit     print number of digits
  -T, --time      print timing
  -c, --check     check result
  index           even index (2..10^7)


CPU:Intel i7-4771 @ 3.5 GHz
Cores / threads: 4 / 8
Program:CalcBn V3.0 64-bit
Options:-t 8 -T -d -s 1000000
Output:Digits: 4767554 / 24
Timing: 56.260 s


Factorizations of the numerators of the Bernoulli numbers, respectively, the Euler numbers with even index 2 to 10 000. Computed prime factors are less than one million, except for known greater prime factors.

Bernoulli numbers  bn_factors.txt
Euler numbersen_factors.txt

Irregular pairs

Computed irregular pairs (p, ) for primes below 20 000.

Bernoulli numbers  bn_irr_pairs.txt
Euler numbersen_irr_pairs.txt

The one millionth Bernoulli number

Number of digits of the numerator / denominator: 4767554 / 24.


More than 4.7 million digits are omitted in the middle of the numerator! (Computed by CalcBn V1.0 on Dec. 16, 2002.)

The 1.5 millionth Bernoulli number

Number of digits of the numerator / denominator: 7415484 / 55.


More than 7.4 million digits are omitted in the middle of the numerator! (Computed by CalcBn V1.2 on Feb. 8, 2003.)

The two millionth Bernoulli number

Number of digits of the numerator / denominator: 10137147 / 31.


More than 10 million digits are omitted in the middle of the numerator! (Computed by CalcBn V1.2 on Feb. 10, 2003.)


  1. J. Bernoulli, Ars Conjectandi, Basel, 1713.
  2. L. Carlitz, The class number of an imaginary quadratic field, Comment. Math. Helv. 27 (1953), 338-345.
  3. L. Carlitz, Note on irregular primes, Proc. Amer. Math. Soc. 5 (1954), 329-331.
  4. T. Clausen, Lehrsatz aus einer Abhandlung über die Bernoulli­schen Zahlen, Astr. Nachr. 17 (1840), 351-352.
  5. R. Ernvall, On the distribution mod 8 of the E-irregular primes, Ann. Acad. Sci. Fenn., Ser. A I, Math. 1 (1975), 195-198.
  6. J. Fresnel, Nombres de Bernoulli et fonctions L p-adiques, Ann. Inst. Fourier 17 (1967), 281-333.
  7. W. Hart, D. Harvey, and W. Ong, Irregular primes to two billion, Math. Comp. 86 (2017), 3031-3049.
  8. D. Harvey, A multimodular algorithm for computing Bernoulli numbers, Math. Comp. 79 (2010), 2361-2370.
  9. D. Hilbert, Die Theorie der algebraischen Zahlkörper, Jahresber. Dtsch. Math.-Ver. 4 (1897), 175-546.
  10. K. L. Jensen, Om talteoretiske Egenskaber ved de Bernoulliske Tal, Nyt Tidss. for Math. 26 (1915), 73-83.
  11. B. C. Kellner, On irregular prime power divisors of the Bernoulli numbers, Math. Comp. 76 (2007), 405-441.
  12. B. C. Kellner, On Asymptotic Constants Related to Products of Bernoulli Numbers and Factorials, Integers 9 (2009), 83-106.
  13. B. C. Kellner, On a product of certain primes, J. Number Theory 179 (2017), 126-141.
  14. B. C. Kellner, Distribution modulo one and denominators of the Bernoulli polynomials, preprint, 1708.07119, Aug. 2017.
  15. B. C. Kellner and J. Sondow, Power-sum denominators, Amer. Math. Monthly 124 (2017), 695-709.
  16. B. C. Kellner and J. Sondow, The denominators of power sums of arithmetic progressions, preprint, 1705.05331, May 2017.
  17. T. Kubota and H. W. Leopoldt, Eine p-adische Theorie der Zetawerte. I: Einführung der p-adischen Dirichletschen L-Funktionen, J. Reine Angew. Math. 214/215 (1964), 328-339.
  18. E. E. Kummer, Allgemeiner Beweis des Fermatschen Satzes, daß die Gleichung xλ+yλ=zλ durch ganze Zahlen unlösbar ist, für alle diejenigen Potenz-Exponenten λ, welche ungerade Primzahlen sind und in den Zählern der ersten ½(λ-3) Bernoullischen Zahlen als Factoren nicht vorkommen, J. Reine Angew. Math. 40 (1850), 131-138.
  19. E. E. Kummer, Über eine allgemeine Eigenschaft der rationalen Entwicklungscoëfficienten einer bestimmten Gattung analytischer Functionen, J. Reine Angew. Math. 41 (1851), 368-372.
  20. R. Rado, A note on the Bernoullian numbers, J. Lond. Math. Soc. 9 (1934), 88-90.
  21. C. L. Siegel, Zu zwei Bemerkungen Kummers, Nachr. Akad. Wiss. Göttingen, II. Math.-Phys. Kl. 6 (1964), 51-57.
  22. K. G. C. von Staudt, Beweis eines Lehrsatzes die Bernoulli­schen Zahlen betreffend, J. Reine Angew. Math. 21 (1840), 372-374.
  23. S. S. Wagstaff, Jr., Prime divisors of the Bernoulli and Euler numbers, Number theory for the millennium III, Proceedings of the millennial conference on number theory, (2002), 357-374.
  24. J. Worpitzky, Studien über die Bernoullischen und Eulerschen Zahlen, J. Reine Angew. Math. 94 (1883), 203-233.


  1. H. Cohen, Number Theory, Volume II: Analytic and Modern Tools, GTM 240, Springer-Verlag, New York, 2007.
  2. K. Ireland and M. Rosen, A Classical Introduction to Modern Number Theory, 2nd ed., GTM 84, Springer-Verlag, New York, 1990.
  3. N. Koblitz, p-adic Numbers, p-adic Analysis and Zeta-Functions, 2nd ed., GTM 58, Springer-Verlag, New York, 1996.
  4. V. V. Prasolov, Polynomials, D. Leites, transl., 2nd ed., ACM 11, Springer-Verlag, Berlin, 2010.
  5. L. C. Washington, Introduction to Cyclotomic Fields, 2nd ed., GTM 83, Springer-Verlag, New York, 1997.