题解 | #判断斐波那契数组#
判断斐波那契数组
https://www.nowcoder.com/practice/9df2a366eb25495caff41612bd0ffca6
<!DOCTYPE html> <html> <head> <meta charset=utf-8> </head> <body> <script type="text/javascript"> const _isFibonacci = array => { // 补全代码 let res = false; let resNum = 0; for(let i=0; i<array.length; i++) { let resNum = (1/Math.sqrt(5)) * (Math.pow(((1+Math.sqrt(5))/2), i) - Math.pow(((1-Math.sqrt(5))/2), i)); if (array[i] === parseInt(resNum)) { res = true; } else { res = false; } } return res; } </script> </body> </html>数学方法试一试
#牛客专项练习#