(I commented these out). For some students it works fine, but for others it thinks the correct answer is something involving e- it seems to be just converting scientific notation in some funky way. While the code below works, it does not allow students to use the C(n,k) notation to enter their answers, which is why I wanted to use the IntegerFunctions context.

Any help would be greatly appreciated.

TEXT(beginproblem());

$showPartialCorrectAnswers = 1;

Context("IntegerFunctions");

$n = random(20,30,1);

$k = random(int(.7*$n), int(.9*$n),1);

$ans = 0;

for ($i = $k; $i<($n+1); $i++){

$ans = $ans + fact($n)/fact($i)/fact($n - $i)/2**$n;

}

# $ans=Compute($ans);

BEGIN_TEXT

A man claims to have extrasensory perception. As a test, a fair coin is flipped \($n\) times, and the man is asked to predict the outcome in

advance. He gets \($k\) out of \($n\) correct. What is the probability that he would have done at least this well if he had no ESP? $BR

\{ans_rule(20)\}

END_TEXT

#ANS($ans->cmp() );

ANS(num_cmp($ans));

ENDDOCUMENT(); # This should be the last executable line in the problem.