# 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: Jun 05, 2023

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

$1$, $4$, $9$, ... 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:

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, $1$. The next one would be... $3$. Surprised?

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

• We started from the previous triangular number, $1$; 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 $3$, we add other three dots at the bottom. The sides, composed initially of two dots, now count, accordingly, $3$.

The geometrical construction of triangular numbers is pretty straightforward. To find the numbers themselves, simply count the dots in each triangle: $1$, $3$, $6$, and so on.

Can you list the first 5 triangular numbers?

They are: $1$, $3$, $6$, $10$, and $15$.

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:

\footnotesize \begin{align*} T_n & = \sum_{k=1}^nk = 1+2+...+n \\[1.3em] &=\frac{n\cdot (n+1)}{2} \\[1.1em] &= \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 $\binom{n}{k}$ counts the number of subsets of size $k$ you can build starting from $n$ elements.

🙋 The series we sum to generate the $k^{\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 $k$.

## 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).

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 $n$ ($5$, in this case), which is also the value of one of the rectangle's sides. The rectangle's other side is equal to $n+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.

$\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:

$\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 $\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 $T_1=1$ gives us the first step on the ladder. We need to prove that if the relation:

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

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

We expand the formula above and proceed from there:

\footnotesize \begin{align*} T_{k+1}&=1+2+...+k + (k+1) \\[0.5em] &= \frac{k\cdot(k+1)}{2}+(k+1)\\[1em] & = \frac{k\cdot(k+1)}{2}+\frac{2\cdot(k+1)}{2}\\[1em] &=\frac{k^2+3k+2}{2}\\[1em] &=\frac{(k+1)(k+2)}{2}\\[1em] &=\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+1$:

\footnotesize \begin{align*} T_{\textcolor{red}{k}} &= \frac{\textcolor{red}{k}\cdot (\textcolor{red}{k}+1)}{2} \\[1em] 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:

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 $T_{n}$ and $T_{n+1}$, as per the example above.

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

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

Triangular numbers are also related to the hexagonal numbers, and since , we expected it. Hexagonal numbers are numbers you can arrange in the shape of the perimeter of a regular hexagon. Starting from $1$, alternating triangular numbers are hexagonal numbers: $1$, $6$, $15$, $28$, and so on.

Let's go on! There is a relationship between triangular numbers and Mersenne primes, a particular type of prime number in the form $2^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 $M_p$:

$\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: $M_p = 2^p-1 \rightarrow M_p+1 = 2^p$.

The sequence grows rapidly: the numbers that satisfy this rule are $T_{M_p}=6$, $28$, $496$, $8128$, $33550336$, $8589869056$...

We are not commenting on this, just appreciating!

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

$\footnotesize T_{n-2},\ T_{n-1},\ T_{n},\ T_{n+1},\ T_{n+2}$

Let's sum them:

\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( \textcolor{red}{(n-2)(n-1)} + \textcolor{blue}{(n-1)\cdot n} \\ &\qquad + \textcolor{green}{n\cdot(n+1)} + \textcolor{magenta}{(n+1)(n+2)} \\ &\qquad + \textcolor{orange}{(n+2)(n+3)}\big) \\[1em] &= \tfrac{1}{2}(5n^2+5n+10)\\[1em] &= T_n+5 \end{align*}

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 $n$ nodes, then the number of connections is $T_{n-1}$:

• For a single node, $n=1$ and $T_{0}=0$;
• For two nodes, $n=2$ and $T_{1}=1$;
• For $n=3$, $T_{2}=3$;
• For $n=4$, $T_{3}=6$.

🙋 This result is also a solution to the handshake problem: how many handshakes will be in a party with $n$ guests? With a bit of order, we can assume that the first guest shakes $n-1$ hands, the second $n-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 $T_n$ from the value of $n$; 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 $T_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 of the project, you can find the list of the first triangular numbers. We report it here, partially:

\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.