Floyd’s triangle can be defined as a series of numbers which are sequentially spread across a series of rows. It is named after Robert Floyd. This triangle is simply a right-angle triangular array of natural numbers, and printing it in standard format is a very famous problem in higher level programming languages.
In this post, I have presented a simple algorithm and flowchart for Floyd’s triangle along with a brief introduction to Floyd’s triangle and some of its important properties.
In Floyd’s triangle, the element of first row is 1 and the second row has 2 and 3 as its member. The next row contains 4, 5 and 6, and the numbers continue in this pattern infinitely. So, it seems quite simple, and the trick used in the Floyd’s triangle algorithm and flowchart presented in this post. With the help of these, you can write pseudo code and source code for Floyd’s triangle in any high level programming language.
Properties of Floyd’s Triangle:
- Floyd’s Triangle is a right angled triangle of natural numbers obtained by filling the rows by consecutive numbers, starting from 1..
- Sequence number of row and number of element in the row are equal, i.e. first row has one element, second has two, and so on.
- 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 sum of nth row is of Floyd’s triangle is equal to n(n2 + 1)/2.
Floyd’s Triangle Algorithm:
- Declare and initialize required variables for controlling loop, inputting number of rows and printing numbers.
- Enter the number of rows to be printed.
- Print the number in standard format utilizing the application of loop as follows
do for x=1 to n
do for y=1 to n
increase the number ans y by 1
go to next line
- Print triangle
Floyd’s Triangle Flowchart:
Floyd’s Triangle C Program
The concept behind the algorithm or flowchart for floyd’s triangle or even its source code is not so complicated. The triangle itself is very important in developing integer and pattern printing techniques which is useful in designing lager computer projects. With the help of algorithm and flowchart presented here, I hope you’ll be able to write the source code for Floyd’s triangle in any high level programming language.