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.