Triangular Numbers- Sequence, Pattern, and Mathematical Properties
What Are Triangular Numbers?
Triangular numbers are the counts of objects that can be arranged into an equilateral triangle. Think of bowling pins before they get knocked down, or cannonballs stacked in a pyramid. Each number in the sequence represents a complete row of dots, with each row containing one more dot than the row above it.
The name sounds fancy, but the concept is dead simple. You start with 1 dot. Add 2 dots below it. Add 3 dots below those. Keep going. The total at any point is a triangular number.
The Sequence and Pattern
The first ten triangular numbers are:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55
Notice the pattern? Each number is the previous one plus the next integer in the counting sequence. 1 + 2 = 3. 3 + 3 = 6. 6 + 4 = 10. And so on.
This makes sense because a triangular number Tn is just the sum of the first n natural numbers:
Tn = 1 + 2 + 3 + ... + n
So T5 = 1 + 2 + 3 + 4 + 5 = 15. Easy.
The Formula
You don't want to add up numbers by hand every time. The closed-form formula is:
Tn = n(n+1)/2
That's it. Plug in any n and you get the nth triangular number instantly.
Quick Examples
- T1 = 1(2)/2 = 1
- T7 = 7(8)/2 = 28
- T100 = 100(101)/2 = 5050
That last one is famous. Carl Friedrich Gauss figured out 1 + 2 + 3 + ... + 100 = 5050 as a kid using the same logic behind this formula.
Key Properties
Even and Odd Pattern
Every other triangular number is even. T2, T4, T6... are even. T1, T3, T5... are odd. This happens because the parity depends on whether n is even or odd in the n(n+1)/2 formula. When n is even, you're multiplying an even number by an odd number and dividing by 2, which always gives an integer.
Relationship to Square Numbers
Two consecutive triangular numbers always add up to a square number:
- T1 + T2 = 1 + 3 = 4 = 22
- T2 + T3 = 3 + 6 = 9 = 32
- T3 + T4 = 6 + 10 = 16 = 42
This pattern holds forever. The reason is algebraic, but the result is clean and useful.
Divisibility Rules
Every triangular number is divisible by its position index if that index is odd. T1 is divisible by 1 (trivially). T3 = 6 is divisible by 3. T5 = 15 is divisible by 5. T7 = 28 is not divisible by 7 because 7 is odd, but wait—28 is divisible by 7 anyway. Actually, Tn is divisible by n when n is odd.
Where Triangular Numbers Show Up
Pascal's Triangle
The third diagonal of Pascal's triangle contains triangular numbers. Each entry in Pascal's triangle is the sum of the two entries above it, and if you look at the right spots, you'll find 1, 3, 6, 10, 15 staring back at you. Specifically, Tn appears at position C(n+1, 2) or C(n+1, n-1)—both are the same value.
Binomial Coefficients
Triangular numbers are binomial coefficients. Tn = C(n+1, 2) = (n+1)!/(2!(n-1)!). This connects them to combinatorics and probability calculations. If you're choosing 2 items from a set of n+1 items, the number of ways is a triangular number.
Polygon Numbers
Triangular numbers are the first in a family of figurate numbers. Square numbers, pentagonal numbers, and hexagonal numbers all follow similar patterns. Triangular numbers are the simplest of the bunch, which is why they appear so often in proofs and examples.
Practical Quick Reference
| n | Tn | Sum of 1 to n |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 3 | 1 + 2 |
| 5 | 15 | 1 + 2 + 3 + 4 + 5 |
| 10 | 55 | 1 through 10 |
| 20 | 210 | 1 through 20 |
| 50 | 1275 | 1 through 50 |
| 100 | 5050 | 1 through 100 |
How to Generate Triangular Numbers
If you need to generate these for a program or calculation:
Method 1: Iterative
sum = 0
for i in range(1, n+1):
sum += i
Method 2: Direct Formula
triangular = n * (n + 1) // 2
The direct formula is faster for large n. No looping required.
Method 3: Recurrence Relation
T[1] = 1
T[n] = T[n-1] + n
This mirrors how the sequence is built: each new triangular number is the previous one plus the next integer.
Why This Matters
Triangular numbers aren't just a math curiosity. They appear in algorithm analysis, particularly in sorting and searching when you're measuring pairwise comparisons. They show up in combinatorial proofs. They describe the number of edges in complete graphs. If you're doing anything with graph theory or discrete math, you'll run into these constantly.
The formula n(n+1)/2 shows up in the wild more often than you'd expect. Handshake problems? That's triangular numbers. Number of games in a round-robin tournament? Also triangular numbers.