Skip to content

Instantly share code, notes, and snippets.

@kolya182
Created July 13, 2017 16:56
Show Gist options
  • Save kolya182/081be6f800ae3a5c61d311f6ef38365f to your computer and use it in GitHub Desktop.
Save kolya182/081be6f800ae3a5c61d311f6ef38365f to your computer and use it in GitHub Desktop.
var generate = function(numRows) {
var result = [1];
if(numRows === 1) {
return [];
}
var container = [1,1];
if (numRows > 1) {
result.push(container);
}
for (var i = 0; i < numRows; i++) {
for (var j = 0; j < container.length; j++) {
console.log(i);
result.push(container.splice(1, 0, (j + (j + 1))));
}
// Inser new
result.push(container);
}
return result;
};
function f(n) {
return f(n - 1) + f(n - 2);
}
console.log(generate(2));
// console.log(f(5));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment