Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,17 @@ console.log(fibonacci(6)); // Output: 8

**Explanation**: Generates the nth Fibonacci number recursively by summing the two preceding numbers.

<sup>[Back to top](#algorithms)</sup>

⚠️ **Note**: This approach has exponential time complexity `O(2^n)` and is inefficient for large inputs.

<sup>[Back to top](#algorithms)</sup>

### Factorial of a Number

```js
function factorial(n) {
if (n < 0) throw new RangeError('Factorial is not defined for negative numbers');

if (n < 0)
throw new RangeError("Factorial is not defined for negative numbers");
if (n === 0 || n === 1) return 1;

return n * factorial(n - 1);
}

Expand Down