Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

prettier triangle

  • Loading branch information...
commit d6c83297740025e7cfed3b16647d7ea2e8ac71ff 1 parent 429ebfe
@substack authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 example/pascal.js
View
13 example/pascal.js
@@ -1,10 +1,17 @@
var choose = require('../');
-var rows = 15;
-for (var n = 0; n < rows; n++) {
+var count = Number(process.argv[2]) || 20;
+var rows = [];
+for (var n = 0; n < count; n++) {
var row = [];
for (var k = 0; k <= n; k++) {
row.push(choose(n, k));
}
- console.dir(row);
+ rows.push(row.join(' '));
}
+
+var len = rows[rows.length - 1].length;
+rows.forEach(function (row) {
+ var n = Math.floor((len - row.length) / 2) + 1;
+ console.log(Array(n).join(' ') + row);
+});
Please sign in to comment.
Something went wrong with that request. Please try again.