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.
It is defined by filling the rows of the triangle with consecutive numbers, starting with a 1 in the top left corner.
<?php
$a = 1;
for($i = 1; $i <= 4; $i++){
for($j = 1; $j <= $i; $j++ ){
echo $a;
$a++;
}
echo '<br/>';
}
?>
Output is:
$a = 1;
for($i = 1; $i <= 4; $i++){
for($j = 1; $j <= $i; $j++ ){
echo $a;
$a++;
}
echo '<br/>';
}
?>
1
23
456
78910
23
456
78910
No comments:
Post a Comment