Practice/expertPascal Triangle Variant
⏱ 00:00
Best: 0/100
Fractals & Modular PascalTarget Time: 20 mins

Pascal Triangle Variant

Given an integer N, print a Sierpinski triangle fractal by computing Pascal’s triangle modulo 2: print "*" if C(n, k) is odd, and " " (space) if even. Align with leading spaces.

Input Format
A single integer N (power of 2 or up to 16).
Output Format
Print N rows forming the fractal.
Constraints:1 <= N <= 16
Concepts Required:
Lucas’ theorem / Parity of binomial coefficientsSierpinski's Gasket fractal geometry
Expected Pattern PreviewASCII Monospace
N=4:
   *
  * *
 *   *
* * * *

Notice how character spacing and row counts scale systematically based on the input N.

Concrete Examples

Example 1
Input:
4
Output:
   *
  * *
 *   *
* * * *

Explanation: Binomial coefficients mod 2 render a Sierpinski fractal.

← Back to All Challenges