Triangular Number Calculator: The n(n+1)/2 Formula and Figurate Patterns
About the Author

A triangular number calculator answers one question fast: what do you get when you add 1 + 2 + 3 + … + n? The answer is always n(n+1)/2, so the sum of the first thousand whole numbers is 1000 × 1001 ÷ 2 = 500,500 — one multiplication and one halving, not 999 additions. Stack that many dots into rows of 1, 2, 3 and so on and you get a perfect equilateral triangle, which is where the name comes from.
The tool above works in three directions. It builds Tn from a row count and draws the dots, it takes any number and tells you whether it is triangular at all, and it sums a partial run like 40 + 41 + … + 90. What follows is the two-line proof of the formula, the reverse test almost nobody is taught, and the handful of numbers that manage to be triangular and something else at the same time.
Pair Them Off: Why n(n+1)/2 Works
The story goes that a schoolteacher in Brunswick told his class to add the numbers 1 to 100, expecting a quiet hour. Nine-year-old Carl Friedrich Gauss handed in 5,050 almost immediately. He had not added anything. He had noticed that 1 + 100 = 101, 2 + 99 = 101, 3 + 98 = 101, and that this keeps working all the way to 50 + 51 = 101. Fifty pairs, 101 each, gives 50 × 101 = 5,050.
The general version is cleaner still. Write the sum forwards, write it again backwards underneath, and add the two rows column by column:
1 + 2 + 3 + … + n
n + n−1 + n−2 + … + 1
─────────────────────────────────
n+1 + n+1 + n+1 + … + n+1 = n(n+1)
Every column adds to n+1, and there are n columns. That total counts the sum twice, so one copy is n(n+1)/2. Geometrically it is the same argument: two identical dot triangles slot together into an n by n+1 rectangle. Take n = 17 and you get 17 × 18 ÷ 2 = 153. Take n = 36 and you get 666, the largest triangular number whose digits are all the same.
One consequence is worth stating on its own, because it is the fastest sanity check you have: n(n+1) is always even, since one of two consecutive integers has to be. So Tn is always a whole number, and any answer with a half in it means the arithmetic went wrong somewhere.
The Off-by-One That Ruins Half the Answers
Most wrong answers here are not arithmetic errors. They are the wrong index. Three formulas look nearly identical and count genuinely different things:
| You want to count | Formula | With 12 people |
|---|---|---|
| 1 + 2 + … + 12 | n(n+1)/2 | 78 |
| Handshakes between 12 people | n(n−1)/2 | 66 |
| Handshakes plus everyone shaking their own hand | n(n+1)/2 | 78 |
The handshake count is Tn−1, not Tn, because the twelfth person has only eleven other hands to shake. Say it out loud once and it sticks: n people, n−1 handshakes each, halved because each handshake was counted twice. The same shape governs a round-robin league. Twenty teams playing everyone once is 20 × 19 ÷ 2 = 190 fixtures; home and away doubles it to 380. Wire 30 servers into a full mesh and you need 435 cables. This is the pairs case of the combination calculator — C(n, 2) and Tn−1 are the same number wearing different notation.
The second trap is partial sums. To add 40 through 90, subtract T39 from T90, not T40: 4,095 − 780 = 3,315. Subtracting T40 quietly drops the 40 you meant to include. The Sum a to b tab handles the fencepost for you and shows both routes to the answer.
The 8N + 1 Test Behind Every Triangular Number Calculator
Going the other way — given a number, is it triangular? — has a clean answer that rarely gets taught. Set n(n+1)/2 = N and rearrange into n² + n − 2N = 0. The quadratic formula gives
Since n has to be a whole number, N is triangular precisely when 8N + 1 is a perfect square. Test 5,050: 8 × 5,050 + 1 = 40,401, and √40,401 = 201 exactly, so n = (201 − 1) ÷ 2 = 100. Test 5,000 instead: 8 × 5,000 + 1 = 40,001, whose square root is 200.0025…, so 5,000 is not triangular. It falls between T99 = 4,950 and T100 = 5,050.
There is a faster filter for the cases that fail. Add up the digits of any triangular number, keep adding until one digit is left, and you will only ever land on 1, 3, 6 or 9. The digital roots run 1, 3, 6, 1, 6, 3, 1, 9, 9 and then repeat forever with period nine. So 5,000 has digital root 5 and can be thrown out in two seconds without touching a square root. That single check eliminates five ninths of all candidates. It never confirms a triangular number — 4,999 has digital root 4+9+9+9 → 31 → 4 and fails, while 100 has root 1 and still is not triangular — but as a rejection tool it is free.
Watch the precision here if you code it yourself. Beyond about 9 quadrillion, a double-precision square root will happily return a whole number for something that is not a perfect square, which is why the calculator above runs the test on exact big integers. The same caution applies whenever you push a square root calculator into very large inputs.
Identities Worth Keeping in Your Head
Triangular numbers connect to almost every other counting sequence, and a few of those links turn awkward problems into one-liners. Here they are with n = 8 worked through each:
| Identity | At n = 8 | What it buys you |
|---|---|---|
| Tₙ = n(n+1)/2 | 36 | The definition, in closed form |
| Tₙ₋₁ + Tₙ = n² | 28 + 36 = 64 | Two consecutive triangles tile a square |
| 8Tₙ + 1 = (2n+1)² | 289 = 17² | The reverse test above |
| Tₙ = C(n+1, 2) | C(9,2) = 36 | Third diagonal of Pascal's triangle |
| T₁ + … + Tₙ = n(n+1)(n+2)/6 | 120 | Tetrahedral numbers — stacked cannonballs |
| Tₙ − Tₙ₋₁ = n | 36 − 28 = 8 | Gaps grow by exactly one each step |
That last row explains why the sequence 1, 3, 6, 10, 15, 21 shows up in puzzle books: its second difference is constant at 1, the signature of a quadratic. Any sequence whose differences increase by a fixed amount is a scaled and shifted triangular sequence, which is exactly what the sequence calculator uses to fit an nth-term rule. The tetrahedral row is the reason the 12 Days of Christmas ends at 364 gifts — the running totals 1, 3, 6, 10 … 78 add up to T-of-T.
Bowling Pins, Pool Racks, and Network Cables
Ten bowling pins in four rows: T4 = 10. Fifteen pool balls in five rows: T5 = 15. Neither sport picked those counts by accident — they are the two smallest triangles that make a satisfying rack. Once you start looking, the sequence turns up wherever something is stacked or paired:
- Scheduling. A 14-team conference playing a single round robin needs T13 = 91 games. Add a second leg and it is 182.
- Network topology. A full mesh of n nodes takes Tn−1 links, so going from 20 to 25 nodes jumps the cable count from 190 to 300 — a 25% headcount increase costing 58% more cable. Quadratic growth is exactly why full meshes get abandoned past a couple of dozen nodes.
- Staircase materials. Blocks stacked in a staircase n steps high need Tn units. A 12-step display wall takes 78 blocks, not 12.
- Testing. Comparing every pair in a set of 10 configurations means 45 test runs. An eleventh configuration adds 10 more, a twelfth adds 11, and by the time you reach 20 you are running 190. The marginal cost of each new item is the item count itself.
The pattern behind all four is the same: anything that pairs every item with every other item grows like n²/2. That is the practical takeaway. Doubling the inputs roughly quadruples the work, which is why estimating these by hand tends to go badly and why the summation calculator is worth reaching for when the sum has a more complicated general term than plain k.
The Rare Numbers That Are Triangular and Something Else
Some triangular numbers moonlight. The square triangular numbers — values that are both Tn and a perfect square — begin 1, 36, 1225, 41616, 1413721 and thin out fast. There are infinitely many, but each is roughly 33.97 times the last, because finding them means solving the Pell equation x² − 8y² = 1 and the solutions grow like powers of 17 + 12√2. So 36 = 6² = T8, and 1,225 = 35² = T49, and then you wait until 41,616 for the next one.
Rarer still, every even perfect number is triangular. 6 = T3, 28 = T7, 496 = T31, 8,128 = T127. The indices 3, 7, 31, 127 are themselves Mersenne primes, which is no coincidence: the Euclid–Euler theorem writes every even perfect number as 2p−1(2p − 1), and that product is exactly T of (2p − 1). Feed 8,128 into the perfect number calculator and the index 127 that comes back is the same 127 the Mersenne prime calculator reports for p = 7.
Two more overlaps are worth knowing. Every hexagonal number is a triangular number with an odd index, Hk = T2k−1, which is why the hexagonal sequence 1, 6, 15, 28, 45 is just every other triangular number. And 1, 3, 21, 55 are the only triangular numbers that also appear in the Fibonacci sequence — a result proved in 1989 and easy to check against the Fibonacci calculator. Only 55 exceeds ten, so the list really is that short. For the full catalogue of terms, the sequence is A000217 in the OEIS.
None of these coincidences make Tn harder to compute — n(n+1)/2 is still one multiplication. They are what makes the sequence worth staring at. Start at the Find Tₙ tab with n = 8 and watch a triangle of 36 dots that a moment's rearrangement also turns into a 6 by 6 square.



