"""
for given n value we have to print the following pascals triangle
if n=5
then output should be 
       1
      1  1
     1  2  1
    1  3  3  1
   1  4  6  4  1
"""

n=int(input())
for i in range(1,n+1):
    for j in range(0,n-i+1):
        print(" ",end="")
    c=1
    for j in range(1,i+1):
        print(" ",c,end="")
        c=c*(i-j)//j
    print()    

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: