Maths & numbers

Consecutive integers from a sum calculator

Recover a run of consecutive integers from its total and length.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

An even number of consecutive integers can have a half-integer average. Subtracting half the spread must still give an integer starting term.

THE FORMULAFirst term = total/count − (count−1)/2

A worked example

Three consecutive integers summing to 63 are 20, 21, and 22.

Good to know

Some totals and counts have no integer solution.

Recover the starting integer from the average

Three consecutive integers with total 63 have average 63/3 = 21. The first of three consecutive integers is one below their average, so the run is 20, 21 and 22. Their sum verifies the result: 20 + 21 + 22 = 63. The calculator returns the first and last terms.

For a run of n terms beginning at a, the terms are a, a + 1, up to a + n − 1. Their average is a + (n − 1)/2. Equating this to total/n and rearranging gives a = total/n − (n − 1)/2. This also explains why subtracting half the span finds the starting term.

Three equal-width bars of heights twenty, twenty-one and twenty-two average to twenty-one202122Mean = 21 · Total = 63
Moving one unit from the 22 bar to the 20 bar makes three equal bars of 21 without changing their total of 63.

Test whether the implied starting value is an integer

A total of 64 across three consecutive integers would require starting value 64/3 − 1 = 20⅓. Since this is not an integer, the requested run does not exist. The formula can always produce a real starting value, but the calculator requires the integer condition before accepting the result.

For two terms totaling 41, the average is 20.5 and the start is 20.5 − 0.5 = 20, giving 20 and 21. A half-integer average is therefore expected for an even number of consecutive integer terms. The Integer quotient and remainder calculator can help inspect divisibility in a proposed sum. This tool accepts a nonnegative total, although the recovered run can include negative integers.

A few questions, answered

What happens when the number of terms is one?

The single term equals the total, so the first and last terms are identical.

Must the first integer be positive?

No. For total 0 and three terms, the formula gives −1, 0 and 1. The first term can be negative.

Find your calculator

Start typing to explore the library.