Skip to content

Instantly share code, notes, and snippets.

View danieljhegeman's full-sized avatar

Daniel Hegeman danieljhegeman

  • Chan Zuckerberg Initiative
View GitHub Profile
@danieljhegeman
danieljhegeman / gist:c185905fd2f4124bb8eeae319948f444
Created January 25, 2018 17:18
Pascal's Triangle - danieljhegeman
var generate = function(numRows) {
result = [];
if (numRows >= 1) {
result = [[1]];
numRows--;
}
for (var i = 0; i < numRows; ++i) {
var prev = result[result.length - 1];
var next = [1]; // initialize
for (var k = 0; k < prev.length - 1; ++k) {