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 07:33, 22 October 2021 (Undo. WP:NOR; Wikipedia is not a code repository). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Floyd's triangle is a 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

The problem of writing a computer program 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.[1][2][3][4]

Properties

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

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. ^ Arora, Ashok; Bansal, Shefali (2005), Unix and C Programming, Firewall Media, p. 387, ISBN 9788170087618
  4. ^ Xavier, C. (2007), C Language And Numerical Methods, New Age International, p. 155, ISBN 9788122411744
  5. ^ Foster, Tony (2015), Doubly Triangular Numbers OEIS A002817.