<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
window.onload = function(){
init();
}
function init(){
console.log(initFb(10));
console.log(initDiv(100));
}
var initFb = (function(){
function fb(n){
if(n <= 0){
return 0;
}
if(n <= 2){
return 1;
}
return fb(n - 1) + fb(n - 2);
}
return fb;
})();
var initDiv = (function(){
function div(n){
var arr = [];
for(var i = 0; i <= n; i++){
if(i % 3 === 0 || i % 5 === 0 || i % 7 === 0){
arr.push(i);
}
}
return arr;
}
return div;
})();
</script>
</body>
</html>
版权声明:本文为weixin_37150764原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。