n =10;
tri = {1};
row1 ={1};
rlength =1;
rowp = row1;
Print[row1]
For[j =1, j<n, j++,
nextrow = {1};
For[i =1, i <rlength , i ++,
temp = rowp[[i]] + rowp[[i+1]];
nextrow =Append[nextrow,temp]];
nextrow = Append[nextrow, 1];
rowp = nextrow;
tri = Append[tri, nextrow];
rlength = rlength + 1;
Print[nextrow]];

n =3;
pri = {1};
tri = {{1}, {1, 1}};
Print[pri];
Print[Column[tri,Center]];
pri = Append[pri, tri];
pretri = tri;
tlength =3;
For[k = 2, k < n, k++,
nexttri = {{1}};
rowlength = 2;
For[r =2, r<tlength , r++,
nextrow = {(pretri[[r-1]][[1]]+pretri[[r]][[1]])};
For[i =2, i < rowlength, i ++,
temp = pretri[[r-1]][[i-1]] + pretri[[r-1]][[i]] +pretri[[r]][[i]];
nextrow = Append[nextrow, temp]];
temp = (pretri[[r-1]][[rowlength-1]]+pretri[[r]][[rowlength]]);
nextrow = Append[nextrow, temp];
rowlength  = rowlength +1;
nexttri = Append[nexttri, nextrow]];
tlength = tlength +1;
lastrow = {1};
For[i =2, i < rowlength, i ++,
temp = pretri[[r-1]][[i-1]] + pretri[[r-1]][[i]] ;
lastrow = Append[lastrow, temp]];
lastrow = Append[lastrow, 1];
nexttri = Append[nexttri, lastrow];
pri = Append[pri, nexttri];
Print[Column[nexttri,Center]];
pretri = nexttri];
Print[pri];

n =6;
(*pri = {1};
tri = {{1}, {1, 1}};*)
toptri={{1}};
For[ tt = 2, tt< n +1, tt++,
row = Array[1&, tt];
toptri = Append[toptri, row]];
pri = {};
Print[Column[toptri,Center]];
pri = Append[pri, toptri];
pretri = toptri;
tlength =n+1;
For[k = 2, k < 2*n , k++,
nexttri = {{1}};
rowlength = 2;
For[r =2, r<tlength , r++,
nextrow = {(pretri[[r-1]][[1]]+pretri[[r]][[1]])};
For[i =2, i < rowlength, i ++,
temp = pretri[[r-1]][[i-1]] + pretri[[r-1]][[i]] +pretri[[r]][[i]];
nextrow = Append[nextrow, temp]];
temp = (pretri[[r-1]][[rowlength-1]]+pretri[[r]][[rowlength]]);
nextrow = Append[nextrow, temp];
(*Print[nextrow];*)
rowlength  = rowlength +1;
nexttri = Append[nexttri, nextrow]];
tlength = tlength +1;
lastrow = {1};
For[i =2, i < rowlength, i ++,
temp = pretri[[r-1]][[i-1]] + pretri[[r-1]][[i]] ;
lastrow = Append[lastrow, temp]];
lastrow = Append[lastrow, 1];
nexttri = Append[nexttri, lastrow];
pri = Append[pri, nexttri];
Print[Column[nexttri, Center]];
pretri = nexttri];
(*Print[Column[pri, Center]];*)