Created
May 25, 2017 16:51
-
-
Save OneCent01/a00309cdee69343545a6ce4fac8365e8 to your computer and use it in GitHub Desktop.
Attempt at pascal's triangle
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 = []; | |
for(var i = 1; i <= numRows; i++) { | |
var inner = []; | |
for(var j = 0; j < i; j++) { | |
inner.push(Math.abs(j + 1)); | |
} | |
if (j%2 > 0) { | |
for(var q = i - 1; q >= 1; q--) { | |
inner.push(Math.abs(q)); | |
} | |
} | |
result.push(inner); | |
} return result; | |
}; | |
generate(5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment