Tagged: Pyramid

PHP Pyramid Part 6

Pyramid in PHP Part VI

<?php $limit = 5; for($i=0;$i<=$limit;$i++) { echo “1”; for($x=1;$x<=$i;$x++) { echo “0”; } echo “1”; echo “<br/>”; } ?> Output: 11 101 1001 10001 100001 1000001  

PHP Pyramid Part 5

Pyramid in PHP Part V

<?php $limit = 5; for($i=0;$i<=$limit;$i++) { for($x=0;$x<$i;$x++) { if($x==0) { echo “1”; continue; } echo “0”; } echo “<br/>”; } ?> Output: 1 10 100 1000 10000  

PHP Pyramid Part 4

Pyramid in PHP Part IV

<?php $limit = 5; for($i=0;$i<=$limit;$i++) { for($k=$i;$k>0;$k–) { echo “*”; } echo “<br/>”; } ?> Output: * ** *** **** *****  

PHP Pyramid Part 3

Pyramid in PHP Part III

<?php $limit = 5; for($i=0;$i<=$limit;$i++) { for($k=$i;$k>0;$k–) { echo $i; } echo “<br/>”; } ?> Output: 1 22 333 4444 55555  

PHP Pyramid Part II

Pyramid in PHP Part II

<?php $limit = 5; for($i=0;$i<=$limit;$i++) { for($k=1;$k<=$i;$k++) { echo $k; } echo “<br/>”; } ?> Output: 1 12 123 1234 12345  

PHP Pyramid Part I

Pyramid in PHP Part I

<?php $limit = 5; for($i=0;$i<=$limit;$i++) { for($k=$i;$k>0;$k–) { echo $k; } echo “<br/>”; } ?> Output: 1 21 321 4321 54321