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