Skip to content

Instantly share code, notes, and snippets.

@e-mihaylin
Created October 3, 2018 14:00
Show Gist options
  • Save e-mihaylin/745039d49a1b1743e9c6b2f339b22ae1 to your computer and use it in GitHub Desktop.
Save e-mihaylin/745039d49a1b1743e9c6b2f339b22ae1 to your computer and use it in GitHub Desktop.
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