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 (wiki):
1 | ||||
2 | 3 | |||
4 | 5 | 6 | ||
7 | 8 | 9 | 10 | |
11 | 12 | 13 | 14 | 15 |
using System; class Program { static void Main(string[] args) { int i, j, k = 1; for (i = 1; i <= 10; i++) { for (j = 1; j < i + 1; j++) { Console.Write(k++ + " "); } Console.Write("\n"); } Console.ReadLine(); } }
Output