Sha256: 282ebfa4abca331511c27e7f990cebcab858ec530e0ea00fc81c82babe534890
Contents?: true
Size: 483 Bytes
Versions: 245
Compression:
Stored size: 483 Bytes
Contents
class PascalsTriangleGenerator { int[][] generateTriangle(int rows) { if (rows < 0) { throw new IllegalArgumentException("Rows can't be negative!"); } int[][] triangle = new int[rows][]; for (int i = 0; i < rows; i++) { triangle[i] = new int[i + 1]; triangle[i][0] = 1; for (int j = 1; j < i; j++) { triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j]; } triangle[i][i] = 1; } return triangle; } }
Version data entries
245 entries across 245 versions & 1 rubygems