递归出题
This commit is contained in:
45
teaching/jwl/课件/js/digui.html
Normal file
45
teaching/jwl/课件/js/digui.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<script>
|
||||
function jiecheng(n){
|
||||
if(n==1){
|
||||
return 1
|
||||
}else{
|
||||
console.log(arguments.callee)
|
||||
return n*arguments.callee(n-1)
|
||||
// 5*5-1 5*4
|
||||
// 5*4*3
|
||||
// 5*4*3*2
|
||||
// 5*4*3*2*1
|
||||
|
||||
}
|
||||
}
|
||||
// 5*4*3*2*1
|
||||
// function jc(n){
|
||||
// if(n==1){
|
||||
// return 1
|
||||
// }else{
|
||||
// return n*a(n-1)
|
||||
// // 5*5-1 5*4
|
||||
// // 5*4*3
|
||||
// // 5*4*3*2
|
||||
// // 5*4*3*2*1
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
var jc=jiecheng
|
||||
jiecheng=null
|
||||
var sum=jc(5) //120
|
||||
console.log(sum)
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user