Created
October 3, 2018 14:00
-
-
Save e-mihaylin/745039d49a1b1743e9c6b2f339b22ae1 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
const getPascalsTriangleRow = n => { | |
const a = []; | |
let x = 0; | |
for (let i = 0; i < n; i++) { | |
x = a.length - i; | |
for (let j = 0; j < i + 1; j++) | |
(j === 0 || j === i) ? a.push(1) : | |
a.push(a[x + j] + a[x + j - 1]); | |
} | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment