Input:
5
Output:
* *** ***** ******* *********
Solution:
$input = 5; // change this with user input
$space = $input;
$asterisk = 1;
for($i=0; $i<$input; $i++) {
echo str_repeat(' ', --$space);
echo str_repeat('*', $asterisk);
echo '<br/>';
$asterisk += 2;
}
Take note that with this solution, you should use a monospace font-family such as Lucida Console or Courier New.
No comments:
Post a Comment