Created
May 18, 2018 18:23
-
-
Save kunyaoxu/e1e1e2fdcf2c17e26aadf5fcb1840673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function nextFibonacci(intArr){ | |
intArr.forEach(function(num) { | |
index = Math.round(Math.log(num/0.4472135955) / Math.log(1.618033988745)); | |
tmp = Math.round(0.4472135955*Math.pow(1.618033988745,index)); | |
if(num < tmp) | |
console.log(tmp); | |
else | |
console.log(Math.round(0.4472135955*Math.pow(1.618033988745,index+1))); | |
}); | |
} | |
nextFibonacci([1,9,22]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment