Skip to content
Omnikalc

Consecutive integers calculator: sum, last number and starting point

Enter the first integer, how many there are and the gap between them to get the last integer, the sum, the average and the sum of the squares, or find the start for a target sum.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Results

Sum

45

Last integer
11
Average
9.0
Sum of the squares
415
First integer for the target sum
13.00
A run of whole numbers exists for this sum

Problems about consecutive integers appear in algebra classes, puzzles and number theory, and the answers all come from the same few formulas. The consecutive integers calculator takes the first integer, the count and the gap to give the last integer, the sum, the average and the sum of the squares, and it finds the first integer for a target sum.

How the calculation works

  • Last integer = first + (count − 1) × gap. With a gap of 1 the numbers are consecutive, and with a gap of 2 they are consecutive even or odd numbers.
  • Sum = count × (2 × first + (count − 1) × gap) ÷ 2, which is the count times the average of the first and last numbers.
  • Average = first + (count − 1) × gap ÷ 2, the middle of the run.
  • Sum of the squares = count × first² + first × gap × (count − 1) × count + gap² × (count − 1) × count × (2 × count − 1) ÷ 6.
  • First integer for a target sum = target ÷ count − (count − 1) × gap ÷ 2. If the result is not a whole number, no run of that length adds up to the target.

Example

Start at 7 with 5 integers and a gap of 1: 7, 8, 9, 10, 11. The last integer is 11, the sum is 5 × (14 + 4) ÷ 2 = 45, the average is 9 and the sum of the squares is 49 + 64 + 81 + 100 + 121 = 415. To reach a sum of 75 with 5 integers, the first one is 75 ÷ 5 − 2 = 13, so the run is 13, 14, 15, 16, 17.

Why it matters

Consecutive integers are the simplest example of an arithmetic sequence, and the formulas help with homework, with tricks such as adding the numbers from 1 to 100 and with checks in programming. Knowing the average of a run lets you add the numbers in your head.

Good to know

The formulas work for negative numbers and for a run that crosses zero. The calculator handles runs up to 1,000 numbers, and the sum of the squares gets large quickly with big starting numbers. For a sum of the first n positive integers, set the first integer to 1 and the gap to 1, which gives n × (n + 1) ÷ 2. For consecutive integers with a gap larger than 1, the term arithmetic sequence is the usual name.

The sequence calculator lists the terms of arithmetic and geometric sequences, and the arithmetic geometric series calculator sums mixed series.

Frequently asked questions

How do I find three consecutive integers with a given sum?

Divide the sum by 3 to get the middle number, then take one less and one more. If the sum is 72, the middle is 24, so the numbers are 23, 24 and 25. Enter the target sum, a count of 3 and a gap of 1 and the calculator gives the first integer directly.

Why does the average sit in the middle?

In a run with a constant gap, the numbers are spread evenly, so each one below the middle is matched by one above it. The average is therefore the middle number for an odd count, and halfway between the two middle numbers for an even count.

How do I work with even or odd integers?

Set the gap to 2 and start from an even number for even integers, or from an odd number for odd integers. For example, 4, 6, 8 and 10 start at 4 with a count of 4 and a gap of 2, and add up to 28.

Why do I sometimes get no whole-number answer?

A run of an odd count always has a whole-number average, but a run of an even count has an average that ends in .5, so its sum is a multiple of the count plus half the count. When the target does not fit that pattern, no run exists, and the calculator shows a fractional start to tell you.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.