My Personal Solution using two dimensional
array
This is my c form code.
#include <stdio.h>
#define N 20
int main() {
int yTri[N][N] = {0};
for(int row = 0; row < N; ++row){
for(int col=0; col<= row; ++col){
if(col==0){
yTri[row][col] = 1;
} else {
yTri[row][col] = yTri[row - 1 ][col - 1] + yTri[row - 1 ][col] ;
}
printf("%4d", yTri[row][col]);
}
printf("\n");
}
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19