Floyd's triangle

{{short description|Triangular array of consecutive natural numbers}}

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:

style="margin:0.5em auto; width:auto"
bgcolor=#F8F8F8 align=center

| 1

bgcolor=#F8F8F8 align=center

| 2

| 3

bgcolor=#F8F8F8 align=center

| 4

| 5

| 6

bgcolor=#F8F8F8 align=center

| 7

| 8

| 9

| 10

bgcolor=#F8F8F8 align=center

| 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.{{citation|title=A first course in computer programming using PASCAL|first=Arthur M.|last=Keller|publisher=McGraw-Hill|year=1982|page=39}}.{{citation|title=Pascal with program design|first=James F.|last=Peters|publisher=Holt, Rinehart and Winston|year=1986|pages=137, 154}}.{{citation|title=Unix and C Programming|first1=Ashok|last1=Arora|first2=Shefali|last2=Bansal|publisher=Firewall Media|year=2005|isbn=9788170087618|page=387|url=https://books.google.com/books?id=p2oawd31_jsC&pg=PA387}}{{citation|title=C Language And Numerical Methods|first=C.|last=Xavier|publisher=New Age International|year=2007|isbn=9788122411744|page=155|url=https://books.google.com/books?id=FYs1-SGPbrQC&pg=PA155}}

Properties

File:centered_square_numbers_vs_triangular_numbers.svgs, highlighted in red, are in found in the center of the odd rows, and are the sum of successive squares – taking 25 as an example, it is the sum of 16 (rotated yellow square) and the next smaller square, 9 (sum of blue triangles)]]

  • 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 {{math|1=n(n2 + 1)/2}}, the constant of an {{math|n × n}} magic square {{OEIS|id=A006003}}.
  • Summing up the row sums in Floyd's triangle reveals the doubly triangular numbers, triangular numbers with an index that is triangular.{{citation|title=Doubly Triangular Numbers OEIS A002817|first=Tony|last=Foster|year=2015}}.

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

{{reflist}}