📜  javascript fibonacci 示例 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:36.233000             🧑  作者: Mango

代码示例4
function fibonacci(num){ 
    var num1=0; 
    var num2=1; 
    var sum; 
    var i=0; 
    for (i = 0; i < num; i++){ 
        sum=num1+num2; 
        num1=num2; 
        num2=sum; 
    } 
    return num2; 
}