Consecutive Integers Calculator

Find the consecutive integers (or consecutive even/odd integers) that add up to a target sum, with the first and last value, the full sequence, and the average calculated instantly.

Quick Facts

Formula
S = n·a + d·n(n-1)/2
a is the first integer; d = 1 for consecutive integers, d = 2 for consecutive even/odd integers.

Your Results

Calculated
First integer
-
Smallest value in the sequence
Last integer
-
Largest value in the sequence
Full sequence
-
All n consecutive values
Average (mean)
-
Equals the sum divided by n

Ready

Enter a target sum, count, and type, then press Calculate.

How the Consecutive Integers Calculator works

Consecutive integers are whole numbers that follow one another in order, each one more than the last: 16, 17, 18 or -4, -3, -2. Consecutive even integers and consecutive odd integers follow the same idea but step by 2 instead of 1: 12, 14, 16 or 7, 9, 11. This calculator solves the classic algebra problem in reverse — given a target sum and how many integers you want, it finds the exact starting value and lists the sequence.

The sum formula

For n consecutive terms starting at a first integer a with common difference d (d = 1 for ordinary consecutive integers, d = 2 for consecutive even or odd integers), the terms are a, a+d, a+2d, ..., a+(n-1)d. Adding them up gives the sum formula:

S = n·a + d · n(n-1)/2

Solving that equation for the unknown first term a gives the formula this calculator uses:

a = S/n − d(n-1)/2

Once a is known, the rest of the sequence is just a + d, a + 2d, and so on, up to the last term a + (n-1)d. For example, three consecutive integers (d = 1) that sum to 51: a = 51/3 − 1×(3−1)/2 = 17 − 1 = 16, giving the sequence 16, 17, 18 (which indeed sums to 51). For three consecutive even integers (d = 2) summing to 42: a = 42/3 − 2×(2)/2 = 14 − 2 = 12, giving 12, 14, 16.

When there is no exact solution

Because a and every term afterward must be whole numbers of the right type, not every sum-and-count combination works. If the formula produces a value of a that is not a whole number, no set of consecutive integers of that count sums to your target — for example, two consecutive integers (x and x+1) always sum to an odd number, so no pair of consecutive integers can ever sum to an even total. If you asked for consecutive even integers but the computed a lands on an odd number (or vice versa for odd), that specific type has no solution either, even though a plain consecutive-integer sequence might.

Checking your result

Two quick checks confirm an answer is right: add up the full sequence shown and confirm it equals your target sum, and confirm each term is exactly d more than the one before it (1 apart for consecutive integers, 2 apart for even or odd). The average shown should also equal the midpoint of the first and last terms — if it does not, something was entered incorrectly.

Applications

This formula is a staple of algebra word problems ("find three consecutive integers whose sum is...") and shows up in puzzles, coding interview warm-ups, and basic number theory. It is also a quick way to check textbook answers or generate practice problems with guaranteed integer solutions.

Frequently Asked Questions

How do you find consecutive integers that add up to a given sum?
Divide the target sum by the count n, then subtract (n-1)/2. That gives the first integer a, and the rest follow by adding 1 each time. For three consecutive integers summing to 51: a = 51/3 - 1 = 16, so the integers are 16, 17, and 18.
How is the formula different for consecutive even or odd integers?
Consecutive even or odd integers differ by 2 instead of 1, so the first term is a = S/n - (n-1) instead of S/n - (n-1)/2. If that value is not a whole number with the right parity (even or odd, matching your choice), no such sequence exists for that sum and count.
Why does my sum have no valid solution?
Not every sum and count combination produces whole numbers. For consecutive integers, the first term must come out to a whole number; for consecutive even or odd integers, it must also land on the right parity. If either check fails, there is no set of consecutive integers of that type meeting the target sum.
What is the average of a set of consecutive integers?
For any evenly spaced sequence, the average equals the midpoint of the first and last terms, (first + last) / 2, which is the same as sum divided by count. For consecutive integers this is the middle value when n is odd, and the midpoint between the two central values when n is even.