This just looks more readable 🙂
Recursion
Mathematics
function fibonacci(n) { return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2) // if (n <= 1) return n; // return fibonacci(n - 1) + fibonacci(n - 2); }
- function fibonacci(n) {
if (n <= 1) return n;return fibonacci(n - 1) + fibonacci(n - 2);- return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2)
- // if (n <= 1) return n;
- // return fibonacci(n - 1) + fibonacci(n - 2);
- }