PHP Program to print Triangle number

Program to print Triangle number

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

Output:

1 
1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 
1 2 3 4 5 6 
Leave a reply
Captcha Click on image to update the captcha .