logoStarPatterns
Back to Patterns

Floyd's Triangle

Pattern Result

1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

Code Implementation

Explanation

Floyd's Triangle is a pattern of numbers that fills a triangle with consecutive integers. Each row contains one more number than the previous row, starting from 1. The pattern continues with consecutive integers, with each number being one more than the previous number. The outer loop iterates from 1 to n, representing each row. The inner loop runs from 1 to the current row number, adding the current value of 'num' to the row string and then incrementing 'num'. This creates a triangle where each position contains the next consecutive integer.