Floyd’s triangle

Floyd’s triangle

Floyd’s triangle, named after Robert Floyd, is a right angled triangle which is made up using natural numbers. It start from 1 and consecutively selects the next greater number in the sequence.

In the Floyd’s triangle, there are n integers in the nth row and total of (n(n+1))/2 integer in the rows.  

Floyd's triangle

1. Write a program to print the following pattern

Enter number of row 5                                                                                                      
1                                                                                                                          
2 3                                                                                                                        
4 5 6                                                                                                                      
7 8 9 10                                                                                                                   
11 12 13 14 15

Working

Step1- Take a number of rows to be printed, n.

Step2- Make outer iteration i for n times to print rows.

Step3- Make inner iteration for j to i.

Step4- print k.

Step5- Increment k.

Step6- Print New Line character after each inner iteration.

Step7- Stop.

One comment on “Floyd’s triangle”