Skip to content

Instantly share code, notes, and snippets.

@omnibusinc
omnibusinc / pascalsTriangle.js
Last active October 13, 2016 14:02
Pascal's Triangle/Pyramid
function buildPascalTriangle(maxLevels, currentLevelNum = 0, previousLevel = []) {
var currentLevel = [];
currentLevel.push(1);
previousLevel.forEach(function(item, idx) {
var value = item + previousLevel[idx+1];
currentLevel.push(value);
});
currentLevel[currentLevelNum] = 1;
console.log(currentLevel);
if(currentLevelNum < maxLevels) {