Ad
Recursion
Mathematics
Code
Diff
  • const fibonacci = n => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);
    
    • function fibonacci(n) {
    • if (n <= 1) return n;
    • return fibonacci(n - 1) + fibonacci(n - 2);
    • }
    • const fibonacci = n => n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);