上楼梯问题
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<script>
function fib(n){
if(n<3){
return 1
}
return fib(n-1)+fib(n-2)
}
console.log(fib(2))
</script>
</body>
</html>
不死兔子
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
function fib(n){
if(n<5){
return 1
}
return fib(n-1)+fib(n-4)
}
console.log(fib(8))
</script>
</body>
</html>