I often have to generate binomial coefficients so I created this simple online utility that does it for me. It lets you calculate the coefficients of the binomial expansion of one or more binomial powers. It works in the browser and is powered by alien technology from the future.

## Binomial Coefficients Generator Options

## Binomial Coefficients Generator Examples (click to try!)

^{n}. It starts from (a+b)

^{0}and ends with (a+b)

^{7}, which is a total of eight powers of n. The coefficients are printed centered and they form the pretty Pascal's triangle.

1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 7 21 35 35 21 7 1

^{20}. In the output, we get all the coefficients for this power separated by spaces.

1 20 190 1140 4845 15504 38760 77520 125970 167960 184756 167960 125970 77520 38760 15504 4845 1140 190 20 1

1 8 28 56 70 56 28 8 1 1 7 21 35 35 21 7 1 1 6 15 20 15 6 1 1 5 10 10 5 1 1 4 6 4 1 1 3 3 1 1 2 1 1 1 1

## How Does This Binomial Coefficients Generator Work?

This binomial coefficient calculator works entirely in your browser and is written in JavaScript. To generate binomial coefficients, it creates a two-dimensional array of coefficients called `coefs`

and initializes it to values `[[1], [1, 1]]`

, which correspond to the first two rows of binomial powers. To calculate the next row, it assigns the current row to a variable `curRow`

and starts a simple `for`

loop over every consecutive pair of values of `curRow`

, finds their sum `curRow[i] + curRow[i+1]`

and `push()`

es them to an empty `newRow`

array. Then it copies the outer values `curRow[0]`

and `curRow[n-1]`

from the current row and puts them at both ends of the `newRow`

array. To calculate `count`

(number of binomial expansion powers to calculate; specified in options), this algorithm is repeated `count`

times. After every loop iteration, `curRow`

is `push()`

ed at the end of the `coefs`

array. When the algorithm finishes, all coefficients get `join()`

ed by the space character. If the center-coefficients option is selected, then it also calls `centerString()`

function for this row of coefficients. If the reverse-powers option is selected, then `coefs`

are first reversed via `coefs.reverse()`

function and all rows are then `join()`

ed by the newline character.

### Created by Browserling

This binomial coefficients generator was created by me and my team at Browserling. Behind the scenes, it's actually powered by Browserling's programmer tools that are used by millions of people every month. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my tools, then I love you, too! Use coupon code COMLING to get a discount at my company Browserling.