Skip to content

Instantly share code, notes, and snippets.

@kunyaoxu
Created May 18, 2018 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunyaoxu/e1e1e2fdcf2c17e26aadf5fcb1840673 to your computer and use it in GitHub Desktop.
Save kunyaoxu/e1e1e2fdcf2c17e26aadf5fcb1840673 to your computer and use it in GitHub Desktop.
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