6 kyu
Pascal's Triangle
5,575 of 11,685boatmeme
Description:
In mathematics, Pascal's triangle is a triangular array of the binomial coefficients expressed with formula
where n
denotes a row of the triangle, and k
is a position of a term in the row.
You can read Wikipedia article on Pascal's Triangle for more information.
Task
Write a function that, given a depth n
, returns n
top rows of Pascal's Triangle flattened into a one-dimensional list/array.
Example:
n = 1: [1]
n = 2: [1, 1, 1]
n = 4: [1, 1, 1, 1, 2, 1, 1, 3, 3, 1]
Note
Beware of overflow. Requested terms of a triangle are guaranteed to fit into the returned type, but depending on selected method of calculations, intermediate values can be larger.
Arrays
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Sep 4, 2013 |
Published | Sep 4, 2013 |
Warriors Trained | 28237 |
Total Skips | 6495 |
Total Code Submissions | 73802 |
Total Times Completed | 11685 |
JavaScript Completions | 5575 |
Ruby Completions | 1381 |
CoffeeScript Completions | 196 |
C# Completions | 1390 |
Haskell Completions | 494 |
PHP Completions | 623 |
Python Completions | 1608 |
Crystal Completions | 14 |
Java Completions | 327 |
Rust Completions | 170 |
C++ Completions | 345 |
C Completions | 85 |
COBOL Completions | 4 |
Total Stars | 640 |
% of votes with a positive feedback rating | 90% of 1503 |
Total "Very Satisfied" Votes | 1251 |
Total "Somewhat Satisfied" Votes | 218 |
Total "Not Satisfied" Votes | 34 |