n=int(input('enter number of rows-'))
n1=1
r1=1
n_r=1
a=0
for i in range(n):#row counter
a=a+1
for z in range(n-a):
print(end=' ')
for m in range(i):#n! Calculator
if (m+1)<=i:
n1=n1*(m+1)
for j in range(i+1):#column counter
for k in range(j):#r! counter
if(k+1)<=j:
r1=r1*(k+1)
for l in range((i-j)+1):#n-r! counter
if(l+1)<=(i-j):
n_r=n_r*(l+1)
co=int(n1/(r1*n_r))
print(co,end=" ")
n_r=1
r1=1
print()
n1=1
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
public class NumberPrimad {
public static void printPyramad(){
for (int i = 1; i <=5; i++){
for (int j = 5; j > i; j--){
System.out.print(" ");
}
for (int k = 1; k <= i; k++){
System.out.print(" "+i+" ");
}
System.out.println();
}
}
public static void main(String args[]){
printPyramad();
}
}
// this just prints the shape of pascal's triangle
Comments
Post a Comment