Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- ##
- ###
- ####
- #####
- ######
- function draw($size)
- {
- for ($i = 1; $i <=$size ; $i++)
- {
- $spaces = $size-$i;
- while ($spaces)
- {
- echo " ";
- $spaces--;
- }
- $stairs = 0;
- while ($stairs < $i)
- {
- echo "#";
- $stairs++;
- }
- echo "<br/>";
- }
- }
- draw(6);
- //output
- #
- ##
- ###
- ####
- #####
- ######
- $max=5;
- for ( $i =1 ; $i<=$max;$i++) {
- for ( $space = 1; $space <= ($max-$i);$space++) {
- echo " ";
- }
- for ( $hash = 1; $hash <= $i;$hash ++ ) {
- echo "#";
- }
- echo "n";
- }
- //PHP
- $n = 6; // Number of rows.
- for($i=1;$i<=$n;$i++){
- echo str_repeat(' ', $n-$i) . str_repeat('#', $i);
- echo 'n';
- }
- for(var i = 0; i < n; i++)
- {
- var s = "";
- for(var j = 0; j < n; j++)
- {
- if(n - i - 2 < j)
- {
- s += "#";
- }
- else
- {
- s += " ";
- }
- }
- console.log(s);
- }
- $int = 7;
- for($i = 1; $i<=$int; $i++){
- printf('%1$s%2$s%3$s',str_repeat(" ",$int-$i),str_repeat("#",$i),"n");
- }
- $n = 6;
- for ($i = 0; $i < $n; $i++) {
- $pad = 1;
- for ($space = 0; $space < $n-$i-1; $space++) {
- $pad++;
- }
- echo str_pad('#', $pad,' ',STR_PAD_LEFT);
- for ($j = 0; $j < $i; $j++) {
- echo '#';
- }
- echo '<br>';
- }
- <?php
- $handle = fopen("php://stdin","r");
- $n = intval(fgets($handle));
- for ($rows = 0; $rows < $n; $rows++) {
- for ($columns = 0; $columns < $n - $rows - 1; $columns++) {
- echo " ";
- }
- for ($columns = 0; $columns < $rows + 1; $columns++) {
- echo "#";
- }
- echo "n";
- }
- ?>
- function staircase($n){
- foreach (range(1, $n) as $i)
- print( str_repeat(' ',$n-$i).str_repeat('#',$i)."n");
- }
- function StairCase(n){
- let x = [];
- for(let i = 0; i<n; i++){
- while(x.length < n){
- x.push(" ");
- }
- x.shift();
- x.push("#");
- console.log(x.join(''));
- } } //StairCase(6)
Add Comment
Please, Sign In to add comment