<html>
<head>
<title></title>
<script src="combination.js">
</script>
</head>
<body>
<script>
n=5;
document.write("recursive method:</br>");
for(m=10;m<=20;m++)
{
if(m%2==0)
n=m/2;
//document.write("---------------------</br>");
start=new Date();
//document.write("m="+m+"n="+n+"</br>");
ans1=recur_combi(m,n);
//document.write("---------------------</br>");
end=new Date();
//document.write("---------------------</br>");
time=end.getTime()-start.getTime();
time=time/1000;
document.write("recursive ans:"+ans1);
document.write(" recursive time:"+time+"sec</br>");
tbody=document.getElementbyId("t1");
row=document.createElement("tr");
col=document.createElement("td");
value=document.createTextNode(m);
col.appendChild(value);
row.appendChild(col);
col=document.createElement("td");
value=document.createTextNode(time);
col.appendChild(value);
row.appendChild(col);
//document.write(m+","+n);
start=new Date();
ans2=loop_combi(m,n);
//document.write("loop ans:"+ans2);
end=new Date();
//document.write("loop ans:"+ans2);
time=end.getTime()-start.getTime();
document.write("loop ans:"+ans2);
document.write(" loop time:"+time/1000+"sec</br>");
col=document.createElement("td");
value=document.createTextNode(time/1000);
col.appendChild(value);
row.appendChild(col);
tbody.appendChild(row);
}
n=5;
document.write("loop method:</br>");
/*for(m=10;m<=20;m++)
{
if(m%2==0)
n=m/2;
start=new Date();
ans2=loop_combi(m,n);
end=new Date();
time=end.getTime()-start.getTime();
document.write("loop ans:"+ans2);
document.write(" loop time:"+time/1000+"sec</br>");
col=document.createElement("td");
value=document.createtextnode(time);
n=m/2;
}*/
</script>
<table name="tab1">
<tbody id="t1">
<tr><th>m</th><th>遞迴方式</th><th>迴圈方式</th></tr>
</tbody>
</table>
</body>
</html>