Polite Number Calculator

Sums

ways to write 15 as a sum of consecutive integers3
the representations1 + 2 + 3 + 4 + 5; 4 + 5 + 6; 7 + 8
odd divisors of 154
longest representation5 terms
How this was calculated
  1. Try every starting value and extend the run of consecutive integers until the sum reaches or passes 15; keep the runs of at least two terms that land exactly on it.
  2. That gives 3 representation(s): 1 + 2 + 3 + 4 + 5; 4 + 5 + 6; 7 + 8.
  3. The count always equals the number of odd divisors of n minus one: 15 has 4 odd divisors, and 4 - 1 = 3.
  4. Only powers of two are impolite (no representation at all); 15 is not a power of two, so at least one representation had to exist.

A polite number can be written as a sum of two or more consecutive positive integers. This calculator takes a number and finds every way it can be written that way. The count is not always obvious: 15 has 3 ways — 1 + 2 + 3 + 4 + 5, 4 + 5 + 6 and 7 + 8 — while 9 has 2 ways (2 + 3 + 4 and 4 + 5) and 45 has 5 ways, the longest running from 1 to 9. Some numbers have none at all. Powers of two are the only impolite numbers, because they have no odd divisor above 1, so 8 has no representation at all. Enter a number and the calculator reports whether it is polite and lists its representations, including those with an even count of terms, which are sometimes called trapezoidal representations.

The method behind the calculator is the standard one for this problem: the number of representations always equals the number of odd divisors of n minus one. That single relationship accounts for every case, from the 3 ways of 15 to the 5 ways of 45 and the zero ways of 8, which is why it is the accepted way to count polite representations. This page shows the formula, the step-by-step workings, worked examples and the sources behind the method, so you can follow each result rather than take it on trust.

Worked examples

Ways to write 15 as consecutive sums

(15)

ways to write 15 as a sum of consecutive integers3
the representations1 + 2 + 3 + 4 + 5; 4 + 5 + 6; 7 + 8
odd divisors of 154
longest representation5 terms

Ways to write 9 as consecutive sums

(9)

ways to write 9 as a sum of consecutive integers2
the representations2 + 3 + 4; 4 + 5
odd divisors of 93
longest representation3 terms

Ways to write 45 as consecutive sums

(45)

ways to write 45 as a sum of consecutive integers5
the representations1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9; 5 + 6 + 7 + 8 + 9 + 10; 7 + 8 + 9 + 10 + 11; 14 + 15 + 16; 22 + 23
odd divisors of 456
longest representation9 terms

What is a polite number?

A polite number is a positive integer that can be written as the sum of two or more consecutive positive integers. The name comes from the idea that the number can be expressed as a "polite" running total — adding 1, then 2, then 3, and so on, without skipping any values. Any number that can be split this way counts as polite, and the interesting question is usually how many different ways it can be done.

Take 15. It has exactly 3 such representations: 1 + 2 + 3 + 4 + 5, then 4 + 5 + 6, and finally 7 + 8. Each uses a different starting point and a different number of terms, but all three add up to 15. Other numbers behave differently. The number 9 has 2 ways: 2 + 3 + 4 and 4 + 5. The number 45 has 5 ways, and its longest run goes from 1 all the way to 9.

There is a clean rule that predicts the count. The number of representations always equals the number of odd divisors of n minus one. So instead of testing sums one by one, you can count how many odd numbers divide the value, subtract one, and you have the answer. This is why some numbers have many representations and others have very few.

Powers of two are the only impolite numbers. They have no odd divisor above 1, so the rule gives them zero representations. The number 8, for example, has no representation at all — no run of two or more consecutive positive integers adds up to 8. Every other positive integer is polite to some degree.

One more term is worth knowing. Representations that use an even count of terms are sometimes called trapezoidal representations, because the terms can be arranged into a staircase shape that resembles a trapezoid. The 15 examples 4 + 5 + 6 and 7 + 8 both fall into this category, while 1 + 2 + 3 + 4 + 5 uses an odd count of terms.

  • 15: 1 + 2 + 3 + 4 + 5, 4 + 5 + 6, and 7 + 8 — 3 ways
  • 9: 2 + 3 + 4 and 4 + 5 — 2 ways
  • 45: 5 ways, with the longest running from 1 to 9
  • 8: no representation at all, because it is a power of two
Quick rule: the number of ways to write n as consecutive positive integers equals the number of odd divisors of n minus one. Powers of two have no odd divisor above 1, so they have no representations — which makes them the only impolite numbers.

The odd divisor rule

The odd divisor rule is the shortcut that turns a search into a count. The number of ways to write a positive integer as a sum of two or more consecutive positive integers always equals the number of odd divisors of that integer minus one. The "minus one" is not a rounding quirk; it removes the representation that the divisor count would otherwise include but that the definition of a polite number excludes. Because a polite number needs at least two terms, the single-term case has to come off the total, and subtracting one odd divisor is exactly how that happens.

Check the rule against 15. The odd divisors of 15 are 1, 3, 5 and 15, so there are 4 of them. Subtract one and you predict 3 representations, and 15 does have 3 ways: 1 + 2 + 3 + 4 + 5, 4 + 5 + 6 and 7 + 8. The count of odd divisors, 4, and the count of sums, 3, differ by exactly one. That is the whole rule in a single example: count the odd divisors, then drop one.

Now check 45, where the numbers are larger and the pattern still holds. The odd divisors of 45 are 1, 3, 5, 9, 15 and 45, which makes 6. Subtract one and the rule predicts 5 representations, and 45 has 5 ways, with the longest running from 1 to 9. Six odd divisors, five sums. The rule does not care how long the runs get or how many terms they contain; it only cares how many odd divisors the number has. That is why a polite number calculator can answer almost instantly: it never has to test sums one by one, because the odd divisor count already contains the answer.

The rule also explains the exceptions. Powers of two are the only impolite numbers. They have no odd divisor above 1, so after the subtraction there is nothing left, and 8 has no representation at all. A number like 9 sits in between: its odd divisors are 1, 3 and 9, so the rule predicts 2 representations, and 9 has 2 ways, 2 + 3 + 4 and 4 + 5. The subtraction stays consistent whether the total is large or small.

One more piece of vocabulary is worth attaching to the rule. Representations with an even count of terms are sometimes called trapezoidal representations. The odd divisor rule counts all representations together, so it covers both the odd-length runs and the even-length trapezoidal ones without treating them separately.

  • 15: odd divisors 1, 3, 5, 15 = 4; 4 − 1 = 3 ways (1 + 2 + 3 + 4 + 5, 4 + 5 + 6, 7 + 8).
  • 45: odd divisors 1, 3, 5, 9, 15, 45 = 6; 6 − 1 = 5 ways, the longest running 1 to 9.
  • 9: odd divisors 1, 3, 9 = 3; 3 − 1 = 2 ways (2 + 3 + 4 and 4 + 5).
  • 8: a power of two, so no odd divisor above 1 and no representation at all.
Count the odd divisors, subtract one, and you have the number of ways to write the number as consecutive positive integers.

Impolite numbers

A polite number can be written as a sum of two or more consecutive positive integers, and some numbers have many such representations. The number 15 has 3 ways: 1 + 2 + 3 + 4 + 5, 4 + 5 + 6 and 7 + 8. The number 9 has 2 ways: 2 + 3 + 4 and 4 + 5. The number 45 has 5 ways, with the longest running from 1 to 9. Counting these representations is a tidy exercise, and the count follows a simple rule: the number of representations always equals the number of odd divisors of n minus one.

That rule explains why some numbers have no representations at all. If a number has no odd divisor above 1, the count of odd divisors minus one is zero. The numbers that fit this description are exactly the powers of two: 1, 2, 4, 8, 16, 32 and so on. Every power of two is built entirely from factors of 2, so it has no odd divisor above 1. As a result, powers of two are the only impolite numbers.

Take 8 as the example. Its divisors are 1, 2, 4 and 8. The only odd divisor is 1, which is not above 1, so the number of odd divisors minus one is zero. There is no way to write 8 as a sum of two or more consecutive positive integers. Try the short runs: 1 + 2 = 3, 2 + 3 = 5, 3 + 4 = 7, and 1 + 2 + 3 = 6, 2 + 3 + 4 = 9. Every run either falls short of 8 or jumps past it. The same holds for 4 and 16, and for every other power of two.

The contrast with nearby numbers makes the point clear. The number 9 is not a power of two, and it has 2 representations. The number 15 is not a power of two, and it has 3. The number 45 has 5. Each of these numbers has at least one odd divisor above 1, so the count of representations is at least one. Only the powers of two sit at zero.

Representations with an even count of terms are sometimes called trapezoidal representations. That name comes from the shape the terms make when they are stacked in rows of increasing length. Impolite numbers have none of these either, since they have no representations of any kind. A quick check for impoliteness is therefore simple: divide the number by 2 as many times as possible. If the result is 1, the number is a power of two, and it is impolite.

Powers of two are the only impolite numbers. They have no odd divisor above 1, so 8 has no representation at all.

Finding the representations

A reliable way to find every representation of a number is a sliding-window search. Start with the smallest possible run, 1 + 2, and move the window forward one starting value at a time, extending the run term by term until the sum reaches or passes the target. When the sum equals the number, you have found a representation. When the sum overshoots, stop extending that window and shift the start upward. Because the terms must stay positive, the search has a natural end point: once the starting value is large enough that even two consecutive terms exceed the number, no new runs can appear.

The search also shows why checking every run is more than a bookkeeping exercise. For 15, the window starting at 1 grows to five terms (1 + 2 + 3 + 4 + 5), the window starting at 4 grows to three terms (4 + 5 + 6), and the window starting at 7 grows to two terms (7 + 8) — three ways in all. For 9, the search returns two ways: 2 + 3 + 4 and 4 + 5. For 45, it returns five ways, and the longest of those runs from 1 to 9, a total of 9 terms. That longest run is a useful check on any polite number calculator: if it misses the nine-term window for 45, it is not searching far enough.

The count of results is not arbitrary. The number of representations always equals the number of odd divisors of n minus one. That rule explains the totals above and gives a quick way to test the output of a search: count the odd divisors, subtract one, and compare. It also explains the exceptions. Powers of two are the only impolite numbers, because they have no odd divisor above 1, so 8 has no representation at all.

Runs with an even count of terms are sometimes called trapezoidal representations, a name drawn from the shape the terms make when stacked. The sliding-window method finds these alongside the odd-length runs without needing a separate rule, which keeps the procedure simple to describe and to check.

NumberRepresentationsNotes
1531 + 2 + 3 + 4 + 5; 4 + 5 + 6; 7 + 8
922 + 3 + 4; 4 + 5
455Longest runs 1 to 9 (9 terms)
80Power of two; impolite
Quick check: for 45, the longest representation is 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9, which is 9 terms.

FAQs

What is a polite number?

A polite number is a positive integer that can be written as a sum of two or more consecutive positive integers. For example, the runs add up term by term with no gaps. Any number that has at least one such consecutive run qualifies as polite, while numbers with no such run are called impolite.

In how many ways can 15 be written as consecutive sums?

15 has 3 ways: 1 + 2 + 3 + 4 + 5, then 4 + 5 + 6, and finally 7 + 8. Each of these uses two or more consecutive positive integers, so each counts as a valid representation. That gives 15 exactly 3 consecutive-sum representations in total.

Which numbers are impolite?

Exactly the powers of two are impolite: 1, 2, 4, 8, 16 and so on have no representation at all. These numbers cannot be written as a sum of two or more consecutive positive integers. Every other positive integer does have at least one such consecutive representation.

How many representations does 45 have?

45 has 5 representations, matching its 6 odd divisors minus one. The count of consecutive-sum representations ties to the odd divisors of the number, with one subtracted to get the total. So for 45, the odd divisors give 6, and subtracting one leaves 5 valid representations.

What is the longest representation of 45?

The longest representation of 45 has 9 terms: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9. That run starts at 1 and adds nine consecutive positive integers, reaching 45. It is the longest of the 5 representations that 45 has.

Why do odd divisors control the count?

Each representation corresponds to an odd divisor of n. A run with an odd number of terms is centred on a whole number exactly when an odd divisor provides the length or the middle term. This link between odd divisors and centered runs is why the odd divisors control how many representations a number has.

Sources

Related calculators

Abundant Number Calculator
Classify any whole number as abundant, perfect or deficient from its aliquot sum: the sum of its proper divisors, the abundance or deficiency against the number itself, and the s(n)/n ratio that puts perfect numbers exactly at one.
Amicable Numbers Calculator
Amicable numbers calculator: test whether two numbers are an amicable pair, with the proper-divisor sums for both numbers shown.
Factors Calculator
List every factor of a number and count them — with the factor pairs, the divisor sum and whether the number is prime or a perfect square.