第十次作业
这个作业属于哪个课程 | https://edu.cnblogs.com/campus/sdscfz/SF4 |
---|---|
这个作业要求在哪里 | https://edu.cnblogs.com/campus/sdscfz/SF4/homework/12964 |
这个作业的目标 | 第10次作业 |
// 加法
var fn = function sum(num1,num2){
return num1+num2;
}
var result = fn(12,5);
document.write(result);
// 减法
var fn = function sum(num1,num2){
return num1-num2;
}
var result = fn(12,5);
document.write(result);
// 乘法
var fn = function sum(num1,num2){
return num1*num2;
}
var result = fn(12,5);
document.write(result);
// 除法
var fn = function sum(num1,num2){
return num1/num2;
}
var result = fn(12,5);
document.write(result);
<!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>
</head>
<body>
<script src="./13-2.js"></script>
</body>
</html>
function fib(num){
var arr = [];
if(num == 1){
return arr = [1];
}else if(num == 2){
return arr[1,1];
}else{
arr = [1,1];
var a=1;
var b=1;
var c=1;
var arrlen = arr.length;
for(var i=2;i<num;i++){
arr.push(c);
a=b;
b=c;
c=a+b;
}
return arr;
}
}
alert( fib(1));
alert( fib(2));
alert( fib(3));
alert( fib(4));
alert( fib(5));
alert( fib(8));