Triangular Numbers Calculator

Created by Davide Borchia
Reviewed by Anna Szczepanek, PhD and Rijk de Wet
Based on research by
N. J. A. Sloane Triangular numbers The On-Line Encyclopedia of Integer Sequences
Last updated: Sep 21, 2022

You've already heard of square numbers: now get ready for triangular numbers with our triangular numbers calculator!

Keep reading and you will find everything you need (and don't need) to know about triangular numbers. This field of math is rich in conjectures and open problems: we hope this calculator will stimulate your curiosity!

Here you will learn:

  • What figurate numbers are;
  • What triangular numbers are;
  • How to calculate and build the triangular numbers;
  • The most important properties of triangular numbers;
  • A list of triangular numbers; and
  • Much more!

Figurate numbers: an introduction

11, 44, 99, ... These are the first square numbers. Why "square"? Because you can arrange them in a square shape. If you think of each unit as a dot, the image becomes immediately clear:

The first three square numbers arranged in dots.
11, 44, and 99: the first three square numbers.

Squares are not the only shapes in which you can arrange specific numbers of "dots". Since the time of ancient Greeks, mathematicians have developed a passion for two categories of such numbers:

  • Figurate numbers, which you can arrange in any shape (with any dimensions);
  • Polygonal numbers, which fit into regular polygons.

Polygonal numbers are a subset of figurate numbers and the more interesting of the two types.

What are triangular numbers?

Triangular numbers are numbers you can arrange in the shape of an equilateral triangle. Note that we are not "measuring" the sides as much as we are counting them.

Which numbers can we pack in a triangle? Let's start with the most trivial triangular number, 11. The next one would be... 33. Surprised?

How did we build the second triangular number? Imagine working with "dots".

  • We started from the previous triangular number, 11; and
  • We added a row of dots, enough to create sides of equal length.

In this case, it sufficed to add two dots at the bottom. The remaining sides would use a single dot of this new row and the previous vertex.

We can go on and build the next one too. The steps are the same: add a row, as long as you need to make it composed of the same number of dots that will be on the tilted sides after the addition.

From 33, we add other three dots at the bottom. The sides, composed initially of two dots, now count, accordingly, 33.

triangular numbers
The first three triangular numbers.

The geometrical construction of triangular numbers is pretty straightforward. To find the numbers themselves, simply count the dots in each triangle: 11, 33, 66, and so on.

Gif of triangular numbers
How to build the first four triangular numbers.

Can you list the first 5 triangular numbers?

They are: 11, 33, 66, 1010, and 1515.

Do you see a pattern?

How to find triangular numbers?

You can keep on adding dots and counting to find all the triangular numbers you want, or you can look for a relationship that would easily give you the same result.

Let's introduce the triangular numbers formula:

Tn=k=1nk=1+2+...+n=n(n+1)2=(n+12)\footnotesize \begin{align*} T_n & = \sum_{k=1}^nk = 1+2+...+n \\ &=\frac{n\cdot (n+1)}{2} \\ &= \binom{n +1}{2} \end{align*}

The last equality introduces the binomial coefficient, an essential operation in combinatorics. It is definitely not a fraction, and you can see its definition in the equality before.

The binomial coefficient (nk)\binom{n}{k} counts the number of subsets of size kk you can build starting from nn elements.

🙋 The series we sum to generate the kthk^{\text{th}} triangular number closely resembles the factorial function, apart from the fact that we sum instead of multiply. Donald Knuth, the legendary computer scientist, proposed the name termial (from "terms" instead of factors) and the notation kk.

Proofs for the triangular numbers formula

We can prove the formula for triangular numbers in two different ways:

  • A graphical proof; and
  • An induction proof.

Graphic proof

Take the construction of any triangular number, and rotate it on one side. Now duplicate, flip, and arrange it to create a rectangle (maintaining the spacing between dots).

The graphic proof
Built a rectangle and start counting!

We showed you how to do it in the image above. Now, let's count what's going on there. The triangle has a side nn (55, in this case), which is also the value of one of the rectangle's sides. The rectangle's other side is equal to n+1n+1: this is the best way we can pack them!

Now, let's calculate the "area" of the rectangle, which is the number of dots it contains.

Arect=n(n+1)\footnotesize A_{\text{rect}} = n \cdot (n+1)

We also know that the "area" of the triangle is half the one of the rectangle, thus:

Atri=Arect2=n(n+1)2\footnotesize A_{\text{tri}} = \frac{A_{\text{rect}}}{2} = \frac{n \cdot (n+1)}{2}

The result corresponds to the one you met before — there are n(n+1)2\frac{n\cdot(n+1)}{2} dots in the triangle!

Induction proof

The induction proof of the formula for the triangular numbers is slightly more abstract. Luckily, the trivial case T1=1T_1=1 gives us the first step on the ladder. We need to prove that if the relation:

Tk=1+2+...+k=k(k+1)2\footnotesize T_k = 1+2+...+k = \frac{k\cdot (k+1)}{2}

is true for kk, then it is true also for k+1k+1.

We expand the formula above and proceed from there:

Tk+1=1+2+...+k+(k+1)=k(k+1)2+(k+1)=k(k+1)2+2(k+1)2=k2+3k+22=(k+1)(k+2)2=(k+1)(k+1+1)2\footnotesize \begin{align*} T_{k+1}&=1+2+...+k + (k+1) \\[0.5em] &= \frac{k\cdot(k+1)}{2}+(k+1)\\ & = \frac{k\cdot(k+1)}{2}+\frac{2\cdot(k+1)}{2}\\ &=\frac{k^2+3k+2}{2}\\ &=\frac{(k+1)(k+2)}{2}\\ &=\frac{(k+1)(k+1+1)}{2} \end{align*}

This is the same relationship we assumed to be true before, but for the value k+1k+1:

Tk=k(k+1)2Tk+1=(k+1)(k+1+1)2\footnotesize \begin{align*} T_{\textcolor{red}{k}} &= \frac{\textcolor{red}{k}\cdot (\textcolor{red}{k}+1)}{2} \\ T_{\textcolor{blue}{k+1}} &= \frac{(\textcolor{blue}{k+1})\cdot(\textcolor{blue}{k+1}+1)}{2} \\ \end{align*}

Induction works, and we got our proof!

Properties of the triangular numbers

As for many seemingly unimpressive concepts in math, triangular numbers are a treasure trove of properties and relations. Let's check some of them out!

First: triangular numbers and square numbers are intimately connected. Take any pair of adjacent triangular numbers and sum them: you'll obtain a square number. How?

First, look at the graphic representation:

Summing triangles
The sum of two adjacent triangular numbers is a square!

Easy peasy: it's just a matter of tilting and fitting. What about taking a look at the formula? Let's consider the triangular numbers TnT_{n} and Tn+1T_{n+1}, as per the example above.

Tn+Tn+1=(n2)+(n+12)=n(n+1)2+(n+1)(n+2)2=n2+n+n2+3n+22=2(n2+2n+1)2=(n2+2n+1)=(n+1)2\footnotesize \begin{align*} T_n+T_{n+1}&=\binom{n}{2}+\binom{n+1}{2}\\[0.75em] &=\frac{n(n\!+\!1)}{2}\!+\!\frac{(n\!+\!1)(n\!+\!2)}{2}\\ &=\frac{n^2+n+n^2+3n+2}{2}\\ &=\frac{2\cdot(n^2+2n+1)}{2}\\ &=(n^2+2n+1)\\[0.5em] &=(n+1)^2 \end{align*}

That is the size of a n+1n+1 square number.

Triangular numbers are also related to the hexagonal numbers, and since hexagons are the bestagons, we expected it. Hexagonal numbers are numbers you can arrange in the shape of the perimeter of a regular hexagon. Starting from 11, alternating triangular numbers are hexagonal numbers: 11, 66, 1515, 2828, and so on.

hexagonal numbers
11, 66, 1515, 2828: the hexagonal numbers correspond to alternating triangular numbers. Because the hexagon is the bestagon.

Let's go on! There is a relationship between triangular numbers and Mersenne primes, a particular type of prime number in the form 2k12^k-1. In particular, every even perfect number is a triangular number, and we find them by calculating the triangular number associated with the Mersenne prime MpM_p:

TMp=Mp(Mp+1)2=Mp2p1\footnotesize T_{M_p}=\frac{M_p\cdot (M_p+1)}{2} = M_p \cdot 2^{p-1}

The last equality comes from the definition of Mersenne primes: Mp=2p1Mp+1=2pM_p = 2^p-1 \rightarrow M_p+1 = 2^p.

The sequence grows rapidly: the numbers that satisfy this rule are TMp=6T_{M_p}=6, 2828, 496496, 81288128, 3355033633550336, 85898690568589869056...

We are not commenting on this, just appreciating!

More? Take a triangular number TnT_n, and consider it with its four adjacent numbers, two on each "side":

Tn2, Tn1, Tn, Tn+1, Tn+2\footnotesize T_{n-2},\ T_{n-1},\ T_{n},\ T_{n+1},\ T_{n+2}

Let's sum them:

Tn2+Tn1+Tn+Tn+1+Tn+2=12((n2)(n1)+(n1)n+n(n+1)+(n+1)(n+2)+(n+2)(n+3))=12(5n2+5n+10)=Tn+5\footnotesize \begin{align*} & \textcolor{red}{T_{n-2}} + \textcolor{blue}{T_{n-1}} + \textcolor{green}{T_{n}} + \textcolor{magenta}{T_{n+1}} + \textcolor{orange}{T_{n+2}} \\

&= \tfrac{1}{2} \big(

This result is always true!

Do triangular numbers have applications?

Even if triangular numbers look so abstract, they find some applications. If you have a fully connected network with nn nodes, then the number of connections is Tn1T_{n-1}:

  • for a single node, n=1n=1 and T0=0T_{0}=0;
  • for two nodes, n=2n=2 and T1=1T_{1}=1;
  • for n=3n=3, T2=3T_{2}=3;
  • for n=4n=4, T3=6T_{3}=6.
Trinagular numbers in networks
The number of connections between these 77 computers is T6=21T_6=21.

🙋 This result is also a solution to the handshake problem: how many handshakes will be in a party with nn guests? With a bit of order, we can assume that the first guest shakes n1n-1 hands, the second n2n-2, and so on, till the most introverted of them, which never initiates a handshake.

How to use our triangular numbers calculator?

You can use our triangular numbers calculator in various ways:

  • To build a triangular number;
  • To find the triangular number TnT_n from the value of nn; or
  • To find a specific portion of the sequence of triangular numbers.

If you choose the first option, build, you will see a graphical representation of the triangular number (if you inserted a valid number), and you will be able to download a CSV-ready text file with the number. Maybe you want to play with it!

If you choose generate, simply insert a non-negative integer. We will return the value of the corresponding TnT_n triangular number.

Our triangular numbers calculator's last option is the range one. Select it, then choose a starting and ending value. We will print the range of numbers (if it isn't too long) and give you a link to download it.

The triangular numbers sequence

The on-line encyclopedia of integer sequences, a gold mine for any mathematics enthusiast, lists the triangular number sequence as A000217. On the relevant web page of the project, you can find the list of the first triangular numbers. We report it here, partially:

0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666...\footnotesize \begin{align*} &0,\ 1,\ 3,\ 6,\ 10,\ 15,\ 21,\ 28,\ 36,\ \\ &45,\ 55,\ 66,\ 78,\ 91,\ 105,\ 120,\ \\ &136,\ 153,\ 171,\ 190,\ 210,\ 231,\ \\ &253,\ 276,\ 300,\ 325,\ 351,\ 378,\ \\ &406,\ 435,\ 465,\ 496,\ 528,\ 561,\ \\ &595,\ 630,\ 666... \end{align*}

I know how to find triangular numbers; now what?

Our triangular number calculator guided you in this brief exploration of a relatively obscure field of math. You can keep this knowledge and use it to show off at parties, expand it, or play a little with it.

Discover more about math with our tools, from the perfect square calculator (which follows the triangular numbers calculator) to the magic square calculator (which explores more playful math).

FAQ

What are the first triangular numbers?

Here is a list of triangular numbers: 0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91. To generate them, you can use the formula for the triangular numbers:

Tₙ = n × (n+1)/2.

We consider 0 to be a triangular number because it satisfies this relation (and many other properties of triangular numbers), but together with 1 is a trivial case.