Advertisement
Advertisement
NUMBER THEORY

Triangular Number Calculator — find T(n), test any number, list the sequence

Get the nth triangular number exactly, check whether any number you have is triangular, and print the run of terms around it.

T(n) is the sum of every whole number from 1 to n. Whole numbers only; n = 0 gives 0 by convention.
The tool reports whether this number is triangular and, if it is, which index produces it.
Up to sixty terms. Every value is computed in exact integer arithmetic, so large indices stay precise.
T(n), the nth triangular number
 
Previous term T(n−1)
Next term T(n+1)
Test result
Largest triangular ≤ your number
Sequence:
Advertisement

The triangular number calculator does three related jobs. It returns T(n), the nth triangular number, for any index you enter. It tests any number you have and tells you whether it is triangular and at what index. And it prints a run of consecutive terms so you can see the pattern rather than just one value. Everything is computed in exact integer arithmetic, so a large index gives a precise answer rather than a rounded approximation in scientific notation.

Triangular numbers are the count of dots you can arrange in a filled equilateral triangle: 1, 3, 6, 10, 15, 21 and onwards. Arb Digital publishes this alongside its other free number-theory and sequence tools because the triangular numbers sit at the junction of three topics that are usually taught separately — figurate numbers, arithmetic series and the binomial coefficients — and seeing all three at once makes each one easier.

What This Triangular Number Calculator Does

The headline figure is T(n) for the index you type. Around it you get the previous and next terms, so the gap between consecutive triangular numbers is visible, and two results for the number you asked to test: whether it is triangular, and the largest triangular number that does not exceed it. That second figure is useful when you want to know how far a number sits from the sequence rather than simply that it is not on it.

The sequence listing prints consecutive terms from any starting index. Because it starts wherever you choose, you can look at the very beginning of the sequence or at a window far out along it, which is the usual reason people want a list at all.

How to Use It

  1. Enter the index n to get T(n). The index is the row number of the triangle, so n = 4 means four rows of dots.
  2. Enter a number to test. The tool reports its index if it is triangular, and otherwise names the nearest triangular number below it.
  3. Set how many terms to list and the index to start from, up to sixty terms in one go.
  4. Read the previous and next terms in the grid to see the step size, which grows by exactly one at every position.
  5. Click Calculate to refresh everything after a change.

The Formula

The nth triangular number is the sum of the first n positive integers, and it has a closed form that Wolfram MathWorld states as T(n) = ½n(n + 1) on its triangular number page, along with the equivalent binomial expression T(n) = C(n + 1, 2).

T(n) = 1 + 2 + 3 + … + n = n(n + 1) / 2

Check it at n = 10. The long way gives 1+2+3+4+5+6+7+8+9+10 = 55. The closed form gives 10 × 11 ÷ 2 = 55. The pairing argument is the classic proof: write the sum forwards and backwards under each other, add the columns, and every column totals n + 1, giving n(n + 1) for twice the sum.

There is also a clean test for triangularity. A non-negative integer x is triangular exactly when 8x + 1 is a perfect square, and in that case the index is (√(8x + 1) − 1) / 2. Take x = 5050: 8 × 5050 + 1 = 40401, whose square root is 201 exactly, so the index is (201 − 1) / 2 = 100 and 5050 = T(100). That is the default test value in the calculator, and it is the sum Gauss is said to have collapsed as a schoolboy.

Advertisement

Where the Boundary Sits With Our Sequence Tools

This is worth stating precisely, because the overlap is real. T(n) is the sum of the arithmetic progression 1, 2, 3, …, n, so in one sense every triangular number is an arithmetic series total. Our arithmetic sequence calculator and series sum calculator handle that general problem: any first term, any common difference, any number of terms.

What this page adds is everything specific to the figurate sequence itself — the fixed first term and common difference of one, the indexing, the triangularity test in the reverse direction, and the identities that only hold for this particular family. If your progression starts at 7 and steps by 3, you want the general series tools. If your question is about the sequence 1, 3, 6, 10, 15 by name, you want this one. The geometric sequence calculator covers the multiplicative case, which is a different family entirely.

The Identities Worth Knowing

Consecutive triangular numbers add to a perfect square: T(n − 1) + T(n) = n². Try n = 5, where 10 + 15 = 25. The picture is two triangles fitted together into a square, and it is the fastest way to remember the relationship.

Eight times a triangular number plus one is a perfect square, which is exactly the test used above: 8T(n) + 1 = (2n + 1)². Every triangular number is a binomial coefficient, C(n + 1, 2), which is why the third diagonal of Pascal's triangle reads 1, 3, 6, 10, 15 — you can read that diagonal straight off the Pascal's triangle generator. And the sum of the first n triangular numbers gives the tetrahedral numbers, the three-dimensional analogue, which count spheres stacked in a pyramid.

The triangular numbers are also the first case of a wider family. MathWorld's entry on the polygonal number gives a single formula covering all of them, and setting the polygon size to three recovers T(n) exactly, while four gives the squares and five the pentagonal numbers. That is worth knowing because it explains why the triangularity test does not transfer: each polygon size has its own discriminant.

One more that surprises people: the only triangular numbers that are also perfect squares are 1, 36, 1225, 41616 and so on, a sparse sequence generated by a Pell equation. They thin out fast, and there is no simple formula that lists them alongside the ordinary terms.

Why Exact Integer Arithmetic Matters Here

Ordinary floating-point numbers in a browser are exact only up to about nine quadrillion. Since T(n) grows roughly as n²/2, indices beyond about 134 million push T(n) past that limit, and a naive calculator starts returning values that are close but wrong in their final digits, often displayed in scientific notation that hides the problem.

This tool computes with arbitrary-precision integers instead, so T(100000000) comes back with every digit correct. The triangularity test uses an exact integer square root as well, which matters because a floating-point square root of a very large number can round to a whole value that is not actually the true root — producing a false positive. If you have ever seen a triangularity checker claim a near miss is triangular, that rounding is why.

Reading the Gaps in the Sequence

List the first several terms and the structure gives itself away immediately. The sequence runs 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, and the differences between consecutive terms are 2, 3, 4, 5, 6, 7, 8, 9, 10. The gap between T(n) and T(n + 1) is always exactly n + 1, because moving to the next triangle means adding one more complete row of dots and that row has one more dot than the last.

That single fact explains most of the behaviour people find puzzling. The sequence grows quadratically rather than linearly, so the terms pull apart steadily and any given range of numbers contains fewer and fewer triangular numbers the further out you go. Between 1 and 100 there are thirteen of them; between 1,000,000 and 1,000,100 there is at most one. It is also why the “largest triangular number at or below x” figure in the grid is useful: as x grows, that number can sit a long way below x even though the two look adjacent on a number line.

The second differences are constant at one, which is the signature of a quadratic sequence and the reason the closed form is a degree-two polynomial in n. If you ever meet an unfamiliar integer sequence, taking differences twice is the quickest test for whether a formula of this shape exists at all.

Where Triangular Numbers Turn Up

The handshake problem is the standard example: n + 1 people each shaking hands once with everyone else produce T(n) handshakes, because the count is C(n + 1, 2). The same count answers how many edges a complete graph has, how many distinct pairs can be drawn from a set, and how many comparisons a naive all-pairs algorithm performs. That last one is the reason an O(n²) nested loop is so often described as “triangular”: it does not run n² times, it runs about half that, and the exact count is a triangular number.

They also appear in the number of terms in a symmetric matrix's upper triangle, in the row lengths of a bowling-pin or billiard-rack arrangement, and in the cumulative totals of any process that adds one more unit each period. Anywhere a quantity increases by a constant step and you need the running total, the triangular numbers are the underlying shape.

Want reference tools this precise on your own site?

Arb Digital builds free calculators that earn search traffic because they get the edge cases right. Browse the library, or tell us what your audience keeps searching for.

Browse Free Tools Talk to Arb Digital

Common Mistakes to Avoid

  • Confusing the index with the value. T(10) is 55, not 10; asking for “the tenth triangular number” means the index, not the term you already have.
  • Forgetting to halve in n(n + 1) / 2, which doubles every answer.
  • Testing triangularity with a floating-point square root, which can round a near miss into a false positive on large numbers.
  • Assuming every figurate number behaves the same way — square, pentagonal and hexagonal numbers each have their own formula and their own test.
  • Starting the sequence at 0 in one place and 1 in another, which shifts every index by one and quietly breaks any identity you then apply.

Related Free Tools From Arb Digital

Sum any progression with the arithmetic sequence calculator or the series sum calculator, look at the multiplicative case in the geometric sequence calculator, read the triangular numbers off the third diagonal in the Pascal's triangle generator, and explore another classic integer arrangement with the magic square generator. The free online tools hub lists every mathematics tool we publish.

Frequently Asked Questions

What is a triangular number?

A number of dots that can be arranged in a filled equilateral triangle. The sequence runs 1, 3, 6, 10, 15, 21 and so on, and the nth term is the sum of every whole number from 1 to n.

What is the formula for the nth triangular number?

T of n equals n times n plus one, divided by two. For n = 10 that gives 10 times 11 divided by 2, which is 55.

How do I check whether a number is triangular?

Multiply it by eight and add one. If the result is a perfect square, the number is triangular, and its index is the square root minus one, all divided by two.

Is zero a triangular number?

By the usual convention yes, as T of 0, since the empty sum is zero. Some texts start the sequence at 1 instead, which shifts every index by one, so check which convention a source is using before comparing indices.

How are triangular numbers related to Pascal's triangle?

Every triangular number is the binomial coefficient of n plus one choose two, so the third diagonal of Pascal's triangle reads exactly 1, 3, 6, 10, 15 and onwards.

Why do two consecutive triangular numbers add to a square?

Because two triangles of dots fit together into a square. Written out, T of n minus one plus T of n equals n squared, which you can check at n = 5 where 10 plus 15 is 25.

Can a triangular number also be a perfect square?

Yes, but rarely. The first few are 1, 36, 1225 and 41616. They are generated by a Pell equation and become very sparse as the numbers grow.

Advertisement
Advertisement

Take it further