Jump to content

Floyd's triangle

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by David Eppstein (talk | contribs) at 20:48, 23 November 2020 (Undid revision 990281725 by 84.245.120.59 (talk) It is highly relevant because its use in programming assignments is the only thing that makes this triangle interesting. Also, once a topic becomes notable for something, later changes in emphasis do not change its former notability. Once notable, always notable. And this is notable as a programming exercise, whether or not it is still assigned that way.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Floyd's triangle is a right-angled triangular array of natural numbers, used in computer 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:

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

Beginning programmers are often assigned the task of writing a program to print out the table in the format shown.[1][2]

The numbers along the left edge of the triangle are the lazy caterer's sequence and the numbers along the right edge are the triangular numbers. The nth row sums to n(n2 + 1)/2, the constant of an n × n magic square (sequence A006003 in the OEIS).

Summing up the row sums in Floyd's triangle reveals the doubly triangular numbers (triangular numbers with an index that is triangular)(sequence A002817 in the OEIS)[3]

1            = 1 = T(T(1))


1            = 6 = T(T(2))
2 + 3

1
2 + 3     = 21 = T(T(3))
4 + 5 + 6

See also

References

  1. ^ Keller, Arthur M. (1982), A first course in computer programming using PASCAL, McGraw-Hill, p. 39.
  2. ^ Peters, James F. (1986), Pascal with program design, Holt, Rinehart and Winston, pp. 137, 154.
  3. ^ Foster, Tony (2015), Doubly Triangular Numbers OEIS A002817.