<html>
<title>测试递归</title>
<head>
<script language=javaScript>
function sum(n)
{
document.write("<b>进入下层递归-n的当前值为:"+n+"</b></br>");
if(n==1)
{
return 0;
}
sum(n-1);
document.write("<b>返回上层递归-n的当前值为:"+n+"</b></br>");
}
</script>
</head>
<body>
<script language=javaScript>
var n=eval(prompt("请输入N的值(正数,不能为空噢):",""));
sum(n);
</script>
</body>
</html>