Created
July 13, 2017 16:56
-
-
Save kolya182/081be6f800ae3a5c61d311f6ef38365f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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