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