## WeBWorK Problems

### Re: Using binomial coefficient notation C(n,r) in answers

by Glenn Rice -
Number of replies: 0

Here is a variant of Mike's answer that will do what I think you are asking for.  This uses a loop as you said.  I used PGML for this, but you could use PG as Mike did if you must.  I highly recommend switching to PGML though as that is the modern approach.

DOCUMENT();

"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"contextIntegerFunctions.pl",
"PGcourse.pl"
);

TEXT(beginproblem());

Context("IntegerFunctions");
Context()->variables->are(n => 'Real');

$k = random(2, 6);$ans_str = "";
$ans_str .= "(n -$_)" for (1 .. $k);$ans = Formula($ans_str)->with(test_points => [ map { [2 *$_] } 1 .. $k + 1 ]); BEGIN_PGML What is an explicit expression for [C(n + [$k], [$k])]? [C(n + [$k], [$k]) = ] [_]{$ans}{40}
END_PGML

ENDDOCUMENT();