Floyd's triangle is a triangular array of
natural number
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
s used in
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
education. It is named after
Robert Floyd. It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner:
The problem of writing a
computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
to produce this triangle has been frequently used as an exercise or example for beginning computer programmers, covering the concepts of text formatting and simple
loop constructs.
Properties
*The numbers along the left edge of the triangle are the
lazy caterer's sequence
The lazy caterer's sequence, more formally known as the central polygonal numbers, describes the maximum number of pieces of a Disk (mathematics), disk (a pancake or pizza is usually used to describe the situation) that can be made with a given nu ...
and the numbers along the right edge are the
triangular number
A triangular number or triangle number counts objects arranged in an equilateral triangle. Triangular numbers are a type of figurate number, other examples being square numbers and cube numbers. The th triangular number is the number of dots in ...
s. The ''n''th row sums to , the constant of an
magic square
In mathematics, especially History of mathematics, historical and recreational mathematics, a square array of numbers, usually positive integers, is called a magic square if the sums of the numbers in each row, each column, and both main diago ...
.
*Summing up the row sums in Floyd's triangle reveals the
doubly triangular number
In mathematics, the doubly triangular numbers are the numbers that appear within the sequence of triangular numbers, in positions that are also triangular numbers. That is, if T_n=n(n+1)/2 denotes the nth triangular number, then the doubly triangu ...
s, triangular numbers with an index that is triangular.
[.]
1 = 1 = T(T(1))
1 = 6 = T(T(2))
2 + 3
1
2 + 3 = 21 = T(T(3))
4 + 5 + 6
*Each number in the triangle is smaller than the number below it by the index of its row.
See also
*
Pascal's triangle
In mathematics, Pascal's triangle is an infinite triangular array of the binomial coefficients which play a crucial role in probability theory, combinatorics, and algebra. In much of the Western world, it is named after the French mathematician Bla ...
References
{{reflist
External links
Floyd's triangle at Rosetta code
Triangles of numbers
Computer programming
Computer science education