user
Task

Produce an ASCII representation of a Sierpinski triangle of order   **N**.

Example

The Sierpinski triangle of order   **4**   should look like this:

```
                       *
                      * *
                     *   *
                    * * * *
                   *       *
                  * *     * *
                 *   *   *   *
                * * * * * * * *
               *               *
              * *             * *
             *   *           *   *
            * * * *         * * * *
           *       *       *       *
          * *     * *     * *     * *
         *   *   *   *   *   *   *   *
        * * * * * * * * * * * * * * * *

```

Related tasks

* Sierpinski triangle/Graphical for graphics images of this pattern.
* Sierpinski carpet
assistant
(formerly Perl 6)

**Translation of**: Perl

```
sub sierpinski ($n) {
    my @down  = '*';
    my $space = ' ';
    for ^$n {
        @down = |("$space$_$space" for @down), |("$_ $_" for @down);
        $space x= 2;
    }
    return @down;
}
 
.say for sierpinski 4;
```