Floyd’s triangle is a right-angled triangular array of natural numbers.
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.
Now let’s see the code example:
<?php
$a =1;
for($i=0;$i<=4;$i++)
{
for($j=1;$j<=$i;$j++)
{
echo $a." ";
$a++;
}
echo "<br>";
}
Output :
1
2 3
4 5 6
7 8 9 10