Pre-Calculus for Programmers
Expansion coefficients
You are writing the helper that a small algebra tool calls when it needs to expand . It does not need the letters, only the numbers in front of each term, in order.
Given n, return the coefficients of starting with the term in and ending with the term in . That is row n of Pascal's triangle, counting the single 1 at the top as row 0, so the answer always has numbers in it.
Input: n = 4
(a+b)^4 = a^4 + 4a^3b + 6a^2b^2 + 4ab^3 + b^4
Output: [1, 4, 6, 4, 1]Input: n = 0 Output: [1] because (a+b)^0 = 1
Input: n = 1 Output: [1, 1] because (a+b)^1 = a + bn is a whole number from 0 to 30.Run your code to see how it does on the examples. Submit also runs the hidden cases.