dash–calculator

04 Numbers and Counting

How to Calculate Consecutive Integers From Their Sum

Readout 04-0026 · Updated · Standard formula, shown below

First integer 7.00
Last integer
11.00
Result, rounded to 2 decimal places
Sum of the integers
45
Input
How many consecutive integers
5
Input
You enter
Sum of the integers, How many consecutive integers
You get
First integer, Last integer
Rounding
2 dp

This page finds a run of consecutive integers with a given sum. Enter the sum and how many integers there are; you get the first and the last integer of the run. If the first value is not a whole number, no run of that length has that sum.

Formula

For n consecutive integers starting at x: x + (x + 1) + … + (x + n − 1) = nx + n(n − 1) ÷ 2 = S, so x = (S − n(n − 1) ÷ 2) ÷ n and the last integer is x + n − 1.

  • S: the sum
  • n: how many integers
  • x: the first integer

Worked Example

Five consecutive integers add up to 45.

  1. n(n − 1) ÷ 2 = 5 × 4 ÷ 2 = 10
  2. x = (45 − 10) ÷ 5 = 7.00
  3. Last = 7 + 5 − 1 = 11.00
  4. Check: 7 + 8 + 9 + 10 + 11 = 45

How to read the result

A whole-number first value means the run exists. For consecutive even or odd integers the step is 2: x = (S − n(n − 1)) ÷ n. The middle of an odd-length run is always S ÷ n, here 9.

Limits and common mistakes

  • If the first value has a decimal part (for example 7.50), no run of n consecutive integers has that sum.
  • Negative sums work and give negative integers.
  • n must be a whole number.

Frequently Asked Questions

Three consecutive integers sum to 72. What are they?

23, 24 and 25.

Can four consecutive integers sum to 10?

Yes: 1 + 2 + 3 + 4. The formula gives x = 1.

Can two consecutive integers sum to 10?

No: the formula gives 4.50, not a whole number.

What about consecutive even integers?

Use x = (S − n(n − 1)) ÷ n; three consecutive even integers summing to 48 start at 14.

Formula used
in s | Sum of the integers | - | 45 | -
in n | How many consecutive integers | - | 5 | 1 | 1000000
out first | First integer | - | (s - n * (n - 1) / 2) / n | 2
out last | Last integer | - | first + n - 1 | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More on this panel

The whole Numbers and Counting panel →