<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>What happens if a problem runs too long? (choose)</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Below, I created a problem, that I think should run fine, but apparently it is running too long.  I don't know why and how does Lon Capa deal with problems that run too long?<BR>
<BR>
Thanks.<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
<problem><BR>
<script type="loncapa/perl">sub choose{<BR>
#  $n = shift @_;<BR>
#  $r = shift @_;<BR>
#  ($n,$r) = @_;<BR>
  $n = $_[0];<BR>
  $r = $_[1];<BR>
  $nr = $n-$r;<BR>
  return &cas('maxima', "binomial($n,$r)"); <BR>
<BR>
}<BR>
<BR>
$a="";<BR>
$total  = &random(6,8,1)*10;<BR>
$female = &random(30,50,1)+1;<BR>
$male   = $total - $female;<BR>
$atmost = &random(3,4,1);<BR>
$smgroup= $atmost+1;  #just needs to be bigger than $atmost and smaller than $female or $male<BR>
$numerator = 0;<BR>
<BR>
$denominator = choose($total,$smgroup);<BR>
<BR>
<BR>
for($i=0; $i<$atmost; $i++)<BR>
{<BR>
  $numerator += choose($male,$i)* choose($female,$smgroup-$i)/ $denominator;<BR>
<BR>
}<BR>
#$answer = $numerator/choose($total,$smgroup);<BR>
$answer = $numerator;<BR>
$answer = &roundto($answer,4);</script><startouttext />A convention is attended by $total people of whom $female are women and $male are men.  If $smgroup of these people are randomly chosen to receive a door prize, what is the probability that at most $atmost will be men?<BR>
<br /><BR>
RUNS LONG AND NEEDS TO BE CHECKED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<endouttext /><BR>
<numericalresponse answer="$answer" format="5F"><BR>
<responseparam type="tolerance" default="0.00001" name="tol" description="Numerical Tolerance" /><BR>
<responseparam name="sig" type="int_range,0-16" default="0,15" description="Significant Figures" /><BR>
    <textline readonly="no" /><BR>
   <BR>
</numericalresponse><BR>
</problem><BR>
</FONT>
</P>

</BODY>
</HTML>