Skip to content

Instantly share code, notes, and snippets.

@liesislukas
Last active September 15, 2016 05:06
Show Gist options
  • Save liesislukas/b47d604f92e0055a2d32ffbf87032815 to your computer and use it in GitHub Desktop.
Save liesislukas/b47d604f92e0055a2d32ffbf87032815 to your computer and use it in GitHub Desktop.
let getF = (n) => {
if (n < 2) return n;
var a = 0,
b = 1,
result;
for (var i = 2; i <=n; i++ ){
result = a + b;
a = b;
b = result;
}
return result;
}
let time = 0;
let result = 0;
for(let i = 500; i < 505; i++){
time = performance.now();
result = getF(i);
console.log(`F at ${i} is ${result} took time: ${performance.now() - time} ms.`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment