Das Pascalsche Dreieck

Image Screenshot_20240827_111548

Image Screenshot_20240827_112153

Image Screenshot_20240827_115038

Image Screenshot_20240827_115551

Image Screenshot_20240827_115605

Image Screenshot_20240827_115623

Image Screenshot_20240827_115648

Image Screenshot_20240827_121420

print ("Pascalsches Dreieck")
a = [[1]]

i = 0
n = 8

while i < n:
    j = 0
    a.append ([]);
    while j <= len(a [i]):
        if j < (len(a[i])/2):
            x = 0
            while j < (len (a[i])/2):
                if (j == 0):
                    x = 0
                    y = a [i][j]
                else:
                    x = a [i][j-1]
                    y = a [i][j]
                a [i+1].append (x+y)
                j = j + 1
        else:
            x = 1
            while j <= (len (a [i])):
                if (j == (len (a [i]))):
                    x = a [i][j-1]
                    y = 0;
                else:
                    x = a [i][j-1]
                    y = a [i][j]
                a [i+1].append (x+y)
                j = j + 1
    i = i + 1

j = 0
i = 0
x = 6
while i < n:
    j = 0
    k = 0
    while k < int((((n*2)-(i*2)))/2):
        print ("  ", end = "")
        k = k + 1
    while (j < len(a [i])):
        #print ("{num}".format(num=str(a [i][j])).center(int((n*8/(i+1)))), end = "")
        #print ("{num}".format(num=str(a [i][j])).center(int((n*2/(i+1)))), end = "")
        print ("{num}".format(num=str(a [i][j])).center(4), end = "")
        #print (str (a[i][j]) + "   ", end = "")
        j = j + 1
    print ("")
    i = i + 1

Pascalsches Dreieck
                 1
               1   1
             1   2   1
           1   3   3   1
         1   4   6   4   1
       1   5   10  10  5   1
     1   6   15  20  15  6   1
   1   7   21  35  35  21  7   1

print ("Pascalsches Dreieck")
a = [[1]]

i = 0
n = 12

while i < n:
    j = 0
    a.append ([]);
    while j <= len(a [i]):
        if j < (len(a[i])/2):
            x = 0
            while j < (len (a[i])/2):
                if (j == 0):
                    x = 0
                    y = a [i][j]
                else:
                    x = a [i][j-1]
                    y = a [i][j]
                a [i+1].append (x+y)
                j = j + 1
        else:
            x = 1
            while j <= (len (a [i])):
                if (j == (len (a [i]))):
                    x = a [i][j-1]
                    y = 0;
                else:
                    x = a [i][j-1]
                    y = a [i][j]
                a [i+1].append (x+y)
                j = j + 1
    i = i + 1

j = 0
i = 0
x = 6
while i < n:
    j = 0
    k = 0
    while k < int((((n*2)-(i*2)))/2):
        print ("  ", end = "")
        k = k + 1
    while (j < len(a [i])):
        #print ("{num}".format(num=str(a [i][j])).center(int((n*8/(i+1)))), end = "")
        #print ("{num}".format(num=str(a [i][j])).center(int((n*2/(i+1)))), end = "")
        print ("{num}".format(num=str(a [i][j])).center(4), end = "")
        #print (str (a[i][j]) + "   ", end = "")
        j = j + 1
    print ("")
    i = i + 1

Pascalsches Dreieck
                         1
                       1   1
                     1   2   1
                   1   3   3   1
                 1   4   6   4   1
               1   5   10  10  5   1
             1   6   15  20  15  6   1
           1   7   21  35  35  21  7   1
         1   8   28  56  70  56  28  8   1
       1   9   36  84 126 126  84  36  9   1
     1   10  45 120 210 252 210 120  45  10  1
   1   11  55 165 330 462 462 330 165  55  11  1