PHP program to print Floyd Triangle number

Program to print Floyd triangle number

<?php 
$num=1;
for($i=1;$i<=6;$i++)
  {
    for($j=1;$j<=$i;$j++)
     {
       echo $num." "; $num++;
         if($j==$i)
           {
               echo " ";
               echo "<br/>";
           }
       }
   } 
?>

Output:

1 
2 3 
4 5 6 
7 8 9 10 
11 12 13 14 15 
16 17 18 19 20 21 
Leave a reply
Captcha Click on image to update the captcha .