nthFibonacci

Run Settings
LanguageJavaScript
Language Version
Run Command
const nthFibonacci = (n) => { const v5 = Math.sqrt(5) const Phi = (v5 + 1) / 2 const phi = Phi - 1 return Math.round( Math.pow(Phi, n) / v5 - Math.pow(-phi, n) / v5) }; console.log(nthFibonacci(6)); // function fibonacci_nth(i){ // var v5 = Math.sqrt(5), // Phi = ( v5 + 1 ) / 2, // phi = Phi-1; // return Math.round( Math.pow(Phi, i) / v5 - Math.pow(-phi, i) / v5 ); // }
Editor Settings
Theme
Key bindings
Full width
Lines