Total Sums of Coefficients of a Binomial Raised to the Nth-Power
Description:
When you want to get the square of a binomial of two variables x and y, you will have:
And the cube:
It is known from many centuries ago that for an exponent n, the result of a binomial x + y raised to the n-th power is:
Or using the sumation notation:
Each coefficient of a term has the following value:
Each coefficient value coincides with the amount of combinations without replacements of a set of n elements using only k different ones of that set.
Let's see the total sum of the coefficients of the different powers for the binomial:
Task
Create a function that returns (an array) of the coefficients sums from 0 to n (inclusive), where the last element is the sum of all previous elements.
We add some examples below:
for n = 0, return 1, 1
for n = 1, return 1, 2, 3
for n = 2, return 1, 2, 4, 7
for n = 3, return 1, 2, 4, 8, 15
Features of the test
Low Performance Tests
Number of tests = 50
9 < n < 101
High Performance Tests
Number of Tests = 50
99 < n < 5001
N.B. In C, input is limited to 0 <= n <= 63
Similar Kata:
Stats:
Created | Dec 9, 2016 |
Published | Dec 9, 2016 |
Warriors Trained | 942 |
Total Skips | 26 |
Total Code Submissions | 1193 |
Total Times Completed | 378 |
Python Completions | 287 |
Ruby Completions | 48 |
Haskell Completions | 38 |
C Completions | 38 |
Total Stars | 14 |
% of votes with a positive feedback rating | 83% of 101 |
Total "Very Satisfied" Votes | 73 |
Total "Somewhat Satisfied" Votes | 21 |
Total "Not Satisfied" Votes | 7 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |