Computer Science/알고리즘 ( Algorithm )
피보나치 수열 - 황금비율 문제
bugtype
2020. 2. 22. 13:19
너무 멋있는 경이로운 문제다.
황금비율 = 1.618...
https://www.youtube.com/watch?v=SjSHVDfXHQ4
https://artofproblemsolving.com/wiki/index.php/Binet%27s_Formula
function getFibo(n){
const a = Math.pow((1+Math.sqrt(5)) / 2,n)
const b = Math.pow((1-Math.sqrt(5)) / 2,n)
const c = (a-b) / Math.sqrt(5)
return Math.round(c)
}
console.log(getFibo(7));