The Binomial Theorem assures that the sum and product outcome of the following pseudo-code will be equivalent:
sum = 0;
for (int r = 0; r <= n; r++) {
  sum += (n!/((n-r)!r!))(a^(n-r))(b^r);
}

product = (a + b)^n;
where n is a nonnegative integer.  n!/(r!(n-r)!) is the binomial coefficient, pronnounced as "n choose r."

See also:
    binomial coefficient

this was a nodeshell rescue