744

这个作业属于哪个课程 https://edu.cnblogs.com/campus/sdscfz/SF4
这个作业要求在哪里 https://edu.cnblogs.com/campus/sdscfz/SF4/homework/12964
这个作业的目标 第10次作业-递归求斐波那契数列第N项的值
<!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>
        var num = prompt('请输入第几项')
        function fn(n){
            if (n == 1 || n == 2){
                return 1;
            }
            return fn(n-2)+ fn(n-1);
        }
        document.write(fn(num));
    </script>
</body>
</html>
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);


posted @ 2023-05-09 15:47  czx258  阅读(130)  评论(0编辑  收藏  举报