How this calculation works
Faulhaber’s formula expresses a finite sum of integer powers as an exact polynomial in its upper endpoint. This calculator derives the required Bernoulli numbers using the B₁=−1/2 convention, displays every polynomial coefficient and evaluates a requested inclusive interval. The power is not restricted to the familiar square and cube formulas, and rational coefficients remain exact until the integer-valued sum is obtained.
S_p(n)=1/(p+1) Σ_(j=0)^p (−1)^j C(p+1,j) B_j n^(p+1−j), with B₁=−1/2. Sum from a to b is S_p(b)−S_p(a−1).A worked example
For p=4 and endpoints one through five, the sum is 1+16+81+256+625=979. The polynomial is n⁵/5+n⁴/2+n³/3−n/30. Substituting n=5 gives 979 exactly even though the polynomial coefficients include fractions. For endpoints three through five, subtract S₄(2)=17 and obtain 962.
Good to know
Powers are integers 0–20 and endpoints satisfy 1≤first≤last≤10^12. The Bernoulli convention is B₁=−1/2, and the formula includes the corresponding alternating sign. No negative powers, fractional exponents or infinite sums are supported. The polynomial always describes the sum from one to n; only the main metric applies the requested interval subtraction.
Reference: NIST DLMF — Bernoulli polynomial sums of powers (opens in a new tab) ↗
The Bernoulli sign convention and formula must agree
Two common Bernoulli conventions assign opposite signs to the number at index one. This page uses B₀=1 and B₁=−1/2. Its Faulhaber formula also includes (−1)^j, so the n^p contribution from j=1 is positive. Copying the coefficients from one convention into a formula written for the other would reverse that term and give the wrong endpoint behavior.
The displayed Bernoulli table makes the convention explicit. Odd Bernoulli numbers beyond B₁ are zero, which removes many polynomial terms. For p=4 the nonzero entries used are B₀=1, B₁=−1/2, B₂=1/6 and B₄=−1/30. These produce the five, four, three and first-power terms in the worked polynomial.
The Sum of the first n squares calculator uses the fixed square-sum identity. This page derives the corresponding polynomial for every supported nonnegative power.
Inclusive intervals require subtracting the previous endpoint
S_p(n) counts every positive integer through n. To include first=a, subtract S_p(a−1), which removes exactly the earlier terms. Subtracting S_p(a) would mistakenly remove a^p as well. The single-point case a=b is an important check: the difference must equal a^p, not zero.
For p=0, each included positive integer contributes one, so the answer is last−first+1. There is no ambiguous zero-to-the-zero expression because both endpoints are positive and the evaluation uses the polynomial S₀(n)=n. The formula is not used to claim an infinite sum of powers converges; every requested interval here is finite.
Fractional coefficients can produce exact integer totals
The rational denominators in Faulhaber polynomials cancel collectively at integer endpoints. Rounding each coefficient separately can destroy that cancellation, especially for large n where several enormous polynomial terms combine. The implementation stores reduced numerator-denominator pairs and performs exact arithmetic through both endpoint evaluations.
A useful independent identity is S_p(n)−S_p(n−1)=n^p. Checking that polynomial difference coefficient by coefficient verifies the entire formula, rather than only one sample endpoint. Direct summation on small intervals provides a second check. The power cap bounds coefficient growth and keeps the displayed polynomial readable; the large endpoint limit is practical because evaluation does not iterate over every integer in the interval.
A few questions, answered
Why are two different B₁ values found in references?
Bernoulli numbering conventions differ at index one. This calculator consistently uses B₁=−1/2 with the displayed alternating-sign power-sum formula.
Does the polynomial change when I change the first endpoint?
No. S_p(n) always sums from one to n. The requested interval is evaluated as S_p(last) minus S_p(first−1).