题解 | 斐波那契数列
斐波那契数列
https://www.nowcoder.com/practice/aa8ffe28ec7c4050b2aa8bc9d26710e9
function fibonacci(n) {
let a=(1+Math.sqrt(5))/2;
let b=(1-Math.sqrt(5))/2;
return Math.round(((Math.pow(a,n)-Math.pow(b,n))/Math.sqrt(5)))
}
提供一种O(logn)复杂度的解法,采用某个数学公式计算

