This site is supported by donations to The OEIS Foundation.

Template:Number triangle

The {{number triangle}} OEIS Wiki utility template creates a number triangle, either equilateral (default) or rectangular.

Usage

```{{number triangle
| rows =
| title =
| type =
| rows count =
| sep =
| start row = | start column = | indices =
| float =
| style =
| cell style =
| row sums =
| f(n) =
}}
```

Parameters:

• rows: data entries of the number triangle

Optional parameters:

• title: title to show above the number triangle
• type: equi, rect (default: equi)
(default: Equilateral number triangle for type = equi; Rectangular number triangle for type = rect)
• sep: separator for data entries in a row (default: ;) (Use twice at end of each row.)
• rows count: number of rows to display (default: 16; maximum 16)
• sep: separator for data entries in a row (default: ;) (Use twice at end of each row.)
• start row: initial row index (default: 0)
• start column: initial column index (default: 0)
• indices: both, rows, columns, neither (default: both)
• float: left, center, right (default: center)
• style: (default: font-family: serif;)
• cell style: (default: background: #DDDDDD; color: black;)
• row sums: yes or no (default: yes)
• f(n): row sums function (preceded by either tex: or htm: as prefix, defaults to tex:)

Examples

The code

```{{number triangle
| float = left
| title =
| type = whatever
| rows =

0 ;; 0 ; 1 ;; 0 ; 1 ; 2 ;; 0 ; 1 ; 2 ; 3 ;; 0 ; 1 ; 2 ; 3 ; 4 ;;

| row sums = no
| f(n) = <!-- t_n -->
}}
```

yields

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

The code

```{{number triangle
| title =
| type = equi
| rows =

0 ;; 0 ; 1 ;; 0 ; 1 ; 2 ;; 0 ; 1 ; 2 ; 3 ;; 0 ; 1 ; 2 ; 3 ; 4 ;;

| start row = 2 | start column = 0
| rows count = 5
| row sums = yes
| f(n) = htm:
}}
```

yields

 n

 n   −  2

 m  = 0
T  (n, m)

2   0
0
3   0 1
1
4   0 1 2
3
5   0 1 2 3
6
6   0 1 2 3 4
10

0
1
2
3
4

The code

```{{number triangle
| title =
| type = equi
| rows =

0 ;; 0 ; 1 ;; 0 ; 1 ; 2 ;; 0 ; 1 ; 2 ; 3 ;; 0 ; 1 ; 2 ; 3 ; 4 ;;

| start row = 3 | start column = 1
| rows count = 5
| row sums = yes
| f(n) = htm:
}}
```

yields

 n

 n   −  2

 m  = 1
T  (n, m)

3   0
0
4   0 1
1
5   0 1 2
3
6   0 1 2 3
6
7   0 1 2 3 4
10

1
2
3
4
5

The code

```{{number triangle
| float = left
| title =
| rows =

0 ;;
0 ; 1 ;;
0 ; 1 ; 2 ;;
0 ; 1 ; 2 ; 3 ;;
0 ; 1 ; 2 ; 3 ; 4 ;;

| rows count = 4
| indices = no
| style = font-family: sans-serif; font-size: 0.75em;
| cell style = background: black; color: white;
| f(n) = t_n
}}
{{number triangle
| float = right
| title =
| rows =

0 ;;
0 ; 1 ;;
0 ; 1 ; 2 ;;
0 ; 1 ; 2 ; 3 ;;
0 ; 1 ; 2 ; 3 ; 4 ;;

| rows count = 4
| indices = rows
| style = font-family: sans-serif; font-size: 0.75em;
| cell style = background: black; color: white;
| f(n) = t_n
}}
{{number triangle
| float = center
| title =
| rows =

0 ;;
0 ; 1 ;;
0 ; 1 ; 2 ;;
0 ; 1 ; 2 ; 3 ;;
0 ; 1 ; 2 ; 3 ; 4 ;;

| rows count = 4
| indices = columns
| style = font-family: sans-serif; font-size: 0.75em;
| cell style = background: black; color: white;
| f(n) = t_n
}}
```

yields

 ${\displaystyle \textstyle {t_{n}}}$ 0 0 0 1 1 0 1 2 3 0 1 2 3 6
 ${\displaystyle \textstyle {n}}$ ${\displaystyle \textstyle {t_{n}}}$ 0 0 0 1 0 1 1 2 0 1 2 3 3 0 1 2 3 6
 ${\displaystyle \textstyle {t_{n}}}$ 0 0 0 1 1 0 1 2 3 0 1 2 3 6 0 1 2 3

The code

```{{number triangle
| title =
| rows =

0 ;;
0 ; 1 ;;
0 ; 1 ; 2 ;;
0 ; 1 ; 2 ; 3 ;;
0 ; 1 ; 2 ; 3 ; 4 ;;

| f(n) = htm: ''t''{{sub|''n''}}
| type = rect
}}
```

yields

 n

 tn

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

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

The code

```{{number triangle
| title = Test
| rows =

0 ;;
0 ; 1 ;;
0 ; 1 ; 2 ;;
0 ; 1 ; 2 ; 3 ;;
0 ; 1 ; 2 ; 3 ; 4 ;;

| rows count = 5
| f(n) = htm: ''t''{{sub|''n''}}
}}
```

yields

Test
 n

 tn

0   0
0
1   0 1
1
2   0 1 2
3
3   0 1 2 3
6
4   0 1 2 3 4
10

0
1
2
3
4

The code

```{{number triangle
| title = Pascal's triangle
| rows =

1 ,,
1 ,    1 ,,
1 ,    2 ,     1 ,,
1 ,    3 ,     3 ,     1 ,,
1 ,    4 ,     6 ,     4 ,     1 ,,
1 ,    5 ,    10 ,    10 ,     5 ,     1 ,,
1 ,    6 ,    15 ,    20 ,    15 ,     6 ,     1 ,,
1 ,    7 ,    21 ,    35 ,    35 ,    21 ,     7 ,     1 ,,
1 ,    8 ,    28 ,    56 ,    70 ,    56 ,    28 ,     8 ,     1 ,,
1 ,    9 ,    36 ,    84 ,   126 ,   126 ,    84 ,    36 ,     9 ,     1 ,,
1 ,   10 ,    45 ,   120 ,   210 ,   252 ,   210 ,   120 ,    45 ,    10 ,     1 ,,
1 ,	  11 , 	  55 ,   165 ,   330 ,   462 ,   462 ,   330 ,   165 ,    55 ,    11 ,     1 ,,
1 ,	  12 ,	  66 ,	 220 ,	 495 ,	 792 ,	 924 ,	 792 ,	 495 ,	 220 ,	  66 ,	  12 ,	   1 ,,
1 ,	  13 ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	  13 ,	   1 ,,
1 ,	  14 ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	  14 ,	   1 ,,
1 ,	  15 ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	  15 ,	   1 ,,

| sep = ,
| rows count = 13
| f(n) = htm: 2{{^|''n''}}
}}
```

yields

Pascal's triangle
 n

 2 n

0   1
1
1   1 1
2
2   1 2 1
4
3   1 3 3 1
8
4   1 4 6 4 1
16
5 1 5 10 10 5 1
32
6   1 6 15 20 15 6 1
64
7   1 7 21 35 35 21 7 1
128
8   1 8 28 56 70 56 28 8 1
256
9   1 9 36 84 126 126 84 36 9 1
512
10 1 10 45 120 210 252 210 120 45 10 1
1024
11   1 11 55 165 330 462 462 330 165 55 11 1
2048
12   1 12 66 220 495 792 924 792 495 220 66 12 1
4096

0
1
2
3
4
5
6
7
8
9
10
11
12

The code

```{{number triangle
| title = Pascal's triangle
| rows =

1 ,,
1 ,    1 ,,
1 ,    2 ,     1 ,,
1 ,    3 ,     3 ,     1 ,,
1 ,    4 ,     6 ,     4 ,     1 ,,
1 ,    5 ,    10 ,    10 ,     5 ,     1 ,,
1 ,    6 ,    15 ,    20 ,    15 ,     6 ,     1 ,,
1 ,    7 ,    21 ,    35 ,    35 ,    21 ,     7 ,     1 ,,
1 ,    8 ,    28 ,    56 ,    70 ,    56 ,    28 ,     8 ,     1 ,,
1 ,    9 ,    36 ,    84 ,   126 ,   126 ,    84 ,    36 ,     9 ,     1 ,,
1 ,   10 ,    45 ,   120 ,   210 ,   252 ,   210 ,   120 ,    45 ,    10 ,     1 ,,
1 ,	  11 , 	  55 ,   165 ,   330 ,   462 ,   462 ,   330 ,   165 ,    55 ,    11 ,     1 ,,
1 ,	  12 ,	  66 ,	 220 ,	 495 ,	 792 ,	 924 ,	 792 ,	 495 ,	 220 ,	  66 ,	  12 ,	   1 ,,
1 ,	  13 ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	  13 ,	   1 ,,
1 ,	  14 ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	  14 ,	   1 ,,
1 ,	  15 ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	   ? ,	  15 ,	   1 ,,

| sep = ,
| rows count = 13
| type = rect
| f(n) = htm: 2{{^|''n''}}
}}
```

yields

Pascal's triangle
 n

 2 n

0   1
1
1   1 1
2
2   1 2 1
4
3   1 3 3 1
8
4   1 4 6 4 1
16
5 1 5 10 10 5 1
32
6   1 6 15 20 15 6 1
64
7   1 7 21 35 35 21 7 1
128
8   1 8 28 56 70 56 28 8 1
256
9   1 9 36 84 126 126 84 36 9 1
512
10 1 10 45 120 210 252 210 120 45 10 1
1024
11   1 11 55 165 330 462 462 330 165 55 11 1
2048
12   1 12 66 220 495 792 924 792 495 220 66 12 1
4096

0
1
2
3
4
5
6
7
8
9
10
11
12

Automatic triangle line breaks

You may use the {{triangle line breaks}} OEIS Wiki utility template to automatically generate the triangle line breaks.

The code

```{{number triangle
| title =
| rows count = 6
| rows =

{{triangle line breaks| 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 7, }}

| sep = ,
| f(n) = htm: ''t''{{sub|''n''}}
}}
```

yields

 n

 tn

0   0
0
1   0 1
1
2   0 1 2
3
3   0 1 2 3
6
4   0 1 2 3 4
10
5 0 1 2 3 4 5
15

0
1
2
3
4
5

The code

```{{number triangle
| float = left
| title =
| rows =

{{triangle line breaks| 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, }}

| rows count = 8
| start row = 1 | start column = 1
| sep = ,
| f(n) = htm: ''t''{{sub|''n''}}
}}
```

yields

 n

 tn

1   1
1
2   1 2
3
3   1 2 3
6
4   1 2 3 4
10
5   1 2 3 4 5
15
6 1 2 3 4 5 6
21
7   1 2 3 4 5 6 7
28
8   1 2 3 4 5 6 7 8
36

1
2
3
4
5
6
7
8