Decorate Pascal's Triangle Although what is a Pascal's triangle is well-known and we already can generate it, the task is now different:
Output \$n\$ first lines of the Pascal's triangle as colored bricks.
Color number is computed as maximal power of \$d\$, that divides the needed-to-color element or \$7\$ if power is more than \$7\$.
Numbered colors are (\$0\$-based): default, red, green, yellow, blue, magenta, cyan, white (default color is 0th, red is 1st, .. white is 7th).  


Any space-filling (I mean not .,' or " or smth small) character
can be used for bricks, even '\u2588'.  
Whitespace before or after the bricks are optional.  
Brick horizontal length (\$1\$ or \$2\$) is your choice.
You may choose any convenient output method -- ansi text or graphics or HTML or whatever
If you choose output letters or color numbers instead of coloring the triangle itself, you should specify in the text of your answer which character corresponds to which color, but output wouldn't look so nice)   


Input Integers \$n\$ and \$d&gt;1\$ in any convenient method.
This is code-golf, the shortest code in each language wins.
C (gcc),  157 153 143 139  135 bytes
Saved several bytes thanks to @AlexeyBurdin
Saved  4  8 more bytes thanks to @ceilingcat
Outputs with ANSI colors.

long p,a,s,c,L;f(n,d){for(a=0;c=a++-n;puts(&quot;&quot;))for(;p=c&lt;a;printf(c&lt;0?&quot; &quot;:&quot;\e[3%dm@@&quot;,L),s=++c&lt;1?1:s*a/c-s)for(L=0;p*=d,L&lt;7&amp;s%p&lt;1;L++);}

Try it online! (no colors on TIO)
Example output for \$f(40,2)\$

Formula
At row \$r\$ and column \$c-1\$, we have:
$$P_{r,c-1}={r\choose c-1}=\frac{r!}{(c-1)!(r-c+1)!}$$
On the same row and the next column \$c\$, we have:
$$\begin{align}P_{r,c}={r\choose c}&amp;=\frac{r!}{c!(r-c)!}\\
&amp;=\frac{r-c+1}{c}\times\frac{r!}{(c-1)!(r-c+1)!}\\
&amp;=\frac{r-c+1}{c}\times P_{r,c-1}\\
&amp;=\frac{r+1}{c}P_{r,c-1}-P_{r,c-1}\end{align}$$
which is translated as s = s * a / c - s in the C code (with \$a=r+1\$).
Commented
long p, a, s, c, L;               // declare a few 64-bit integers
f(n, d) {                         // n = number of rows, d = colorization parameter
  for(a = 0; a++ &lt; n; puts(&quot;&quot;))   // for a = 1 to n, with a linefeed added after each
    for(                          // iteration:
      c = a + ~n;                 //   for c = a - n - 1 to a - 1:
      p = c &lt; a;                  //
      printf(                     //     update the output after each iteration:
        c &lt; 0 ?                   //       if c is negative:
          &quot; &quot;                     //         just append a space
        :                         //       else:
          &quot;\e[3%dm@@&quot;,            //         append the ANSI color code, followed by '@@'
        L                         //       set the 2nd digit of the color code
      ),                          //
      s = ++c &lt; 1 ? 1             //     increment c; set s to 1 while c is less than 1
                  : s * a / c - s //     then, update s to s * a / c - s
    )                             //
      for(                        //       compute the color L:
        L = 0;                    //         start with L = 0
        p *= d,                   //         multiply p by d
        L &lt; 7 &amp; s % p &lt; 1;        //         stop if L = 7 or p does not divide s
        L++                       //         increment L
      );                          //
}                                 //