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


-module(sierpinski).
-export([triangle/1]).
 
triangle(N) ->
    F = fun(X) -> io:format("~s~n",[X]) end,
    lists:foreach(F, triangle(N, ["*"], " ")).
 
triangle(0, Down, _) -> Down;
triangle(N, Down, Sp) ->
    NewDown = [Sp++X++Sp || X<-Down]++[X++" "++X || X <- Down],
    triangle(N-1, NewDown, Sp++Sp).