Think of a rack of billiard balls, or Pascal's Triangle. You start with 1, add two to get 3, add three to get 6, add four to get 10, add five to get 15, and so forth, each time adding the next natural number to the previous sum. The numbers you produce using this algorithm are the triangular numbers.

        1
      2   3
    4   5   6
  7   8   9  10
11 12  13  14  15

The nth triangular number is defined as the number of elements in a triangle with n rows, that is: n+(n-1)+(n-2)+...+2+1.

Because of this, the nth triangular number can be quickly calculated for any even n:

The nth triangular number
= n+(n-1)+(n-2)+...+(n-n/2)+...+2+1
= n+(n-1)+1+(n-2)+2+...+(n-n/2)
= n+n+n+...+n (repeated n/2 times) +(n-n/2)
= n*(n/2)+n-(n/2)
= n(n/2+1-1/2)
= n(n/2+1/2)
= n(n+1)/2
Similarly, for any odd n:
The nth triangular number
= n+(n-1)+(n-2)+...+(n-(n-1)/2)+(n-1)/2+...+2+1
= n+(n-1)+1+(n-2)+2+...+(n-((n-1)/2)+((n-1)/2))
= n+n+n+...+n (repeated 1+(n-1)/2 times)
= n+n+n+...+n (repeated (n+1)/2 times)
= n(n+1)/2
We can generalize that the nth triangular number equals n(n+1)/2 for any natural number n, and if we like, prove it using mathematical induction.

In combinatorics, integers that can be expressed as triangular arrays of dots. Another charcterization is as the binomial coefficient C(n,4) (for n > 3 ).

An explicit formula for the nth triangular number is:

Tn = n(n+1)/2

--back to combinatorics--
An integer N is a triangular number iff 1+8N is a perfect square. E.g. 10 is triangular, because 1+8*10=81 is a square; 12 is not, because 1+8*12=97 is not a square.

Details why this is so are left as an easy exercise for the interested reader.

According to mathematical legend, when Gauss was a young student, he had a math teacher who liked to keep his students quiet by giving them busy work. One day, he told the class to sum all of the numbers from 1 to 100. (This is the same as finding the 100th triangular number.) Instead of immediately writing, Gauss stared off into space thinking and quickly arrived at the correct answer. How did he do this? Instead of trying to add the numbers up in order, he paired them up.

1   2   3   4   5   6   ...  50
100 99  98  97  96  95  ...  51
\_____________________________/
            50 pairs

Each of these column pairs, he reasoned, added up to 101. And there were 50 pairs. So the sum of the first 100 numbers must be 101*50, or 5050. In other words, he re-derived the formula for triangular numbers: T(n)=(n)(n+1)/2. From there it was a hop, skip, and a jump to T(100)=(100)(101)/2=5050.

Just as any polygon can be considered a set of triangles, any polygonal number can be generated from triangular numbers.

Consider a square number, and two triangular numbers of the same degree:

                               *--*--*--*
*--*--*--*   *--*--*--*         \ |  |  |
|  |  |  |   |\ |  |  |      *   \|  |  |
|  |  |  |   | \|  |  |      |\   *  *  *
*--*  *  *   *--*  *  *      | \   \ |  |
|     |  |   |   \ |  |      *--*   \|  |
|     |  |   |    \|  |      |   \   *  *
*--*--*  *   *--*--*  *      |    \   \ |
|        |   |      \ |      *--*--*   \|
|        |   |       \|      |      \   *
*--*--*--*   *--*--*--*      |       \
                             *--*--*--*
It is clear to see that two triangular numbers will have the same number of dots, except the diagonal gets counted twice. The rth square number (p4r) is twice the rth triangular number (p3r) minus r. Consider pentagonal numbers:
                                                        *   *
         *                     *                       /|   |\
        / \                   /|\                     / | * | \
       /   \                 / | \                   * |  |  | *
      *     *               * | | *                 / \|  |  |/ \
     / \   / \             / \| |/ \               /   * | | *   \
    /   *-*   \           /   *-*   \             *    | | | |    *
   *           *         *    | |    *           / \   | *-* |   / \
  / \         / \       / \   | |   / \         /   * |  | |  | *   \
 /   *       *   \     /   * |   | *   \       *     \|  | |  |/     *
*     \     /     *   *     \|   |/     *       \     * |   | *     /
 \     *-*-*     /     \     *-*-*     /         *    | |   | |    *
  *             *       *    |   |    *           \   | *-*-* |   /
   \           /         \   |   |   /             * |  |   |  | *
    *         *           * |     | *               \|  |   |  |/
     \       /             \|     |/                 * |     | *
      *-*-*-*               *-*-*-*                    |     |
                                                       *-*-*-*
Three triangles, with two diagonals counted twice, make a pentagon, so p5r = (3 * p3r) - (2 * r).

An n-gonal number of degree r, by generalisation, is pnr = ((n - 2) * p3r) - ((n - 3) * r), and p3r = ((r + 1) * r) / 2.

/* a humble program to find the nth triangular number */

#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n = 0;
	int i;

	printf("\nEnter a number to get that nth triangular number: ");
	scanf("%d", &i);

	n = ((i * (i + 1)) / 2);

	printf("\nTriangular number %d is %d.\n\n", i, n);
	system("PAUSE");

	return 0;
}

Log in or register to write something here or to contact authors.