Write a program to print Floyd's triangle number pattern in php language
ADVERTISEMENTS
Write a program to print Floyd's triangle number pattern in php language. There are you will learn how to print Floyd's triangle number pattern by using the for loop.
Consider an example to print out this pattern through a php program:
<?php
// Write a program to print Floyd's triangle
// number pattern in PHP language
$r = 7;
$n = 1;
echo "-----This is Floyd's triangle number pattern-----\n\n";
for ($i = 1; $i <= $r; $i++) {
echo "\t";
for ($j = 1; $j <= $i; ++$j) {
echo $n . " ";
++$n;
}
echo "\n";
}
?>
Output:
-----This is Floyd's triangle number pattern-----
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
Tags:
# Floyd's triangle program in php language
# reverse Floyd's triangle in php language
# Floyd's triangle in python language