aaaa
This commit is contained in:
52
teaching/lhj/kejian/js/digui.html
Normal file
52
teaching/lhj/kejian/js/digui.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=\, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<script>
|
||||
//递归 : 函数中 自己调用自己
|
||||
function jiecheng(n){
|
||||
var jieguo=1
|
||||
for(var i=n;i>0;i--){
|
||||
jieguo=jieguo*i
|
||||
}
|
||||
return jieguo
|
||||
}
|
||||
// console.log(jiecheng(5))
|
||||
// 阶乘 5 =〉5*4*3*2*1
|
||||
|
||||
function jc(m){
|
||||
if(m<=1){
|
||||
return 1
|
||||
}else{
|
||||
return m*jc(m-1)
|
||||
}
|
||||
}
|
||||
// function jc1(m){
|
||||
// if(m<=1){
|
||||
// return 1
|
||||
// }else{
|
||||
// return m*jc(m-1)
|
||||
// }
|
||||
// }
|
||||
|
||||
// 5*jc(4)
|
||||
// 4*jc(3)
|
||||
// 3*jc(2)
|
||||
// 2*jc(1)
|
||||
// 2*1
|
||||
|
||||
// console.log(jc(5))
|
||||
|
||||
var jc1=jc
|
||||
jc=null;
|
||||
console.log(jc1(5))
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user