JavaScript Algorithms and Data Structures: Math - Factorial

Factorial is the product of all the positive integers less than or equal to a given number. Learn how to calculate the factorial of a number in JavaScript.

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example:

5! = 5 * 4 * 3 * 2 * 1 = 120
nn!
01
11
22
36
424
5120
6720
75 040
840 320
9362 880
103 628 800
1139 916 800
12479 001 600
136 227 020 800
1487 178 291 200
151 307 674 368 000

References

Wikipedia

Read this in other languages: 简体中文, français.

The Original Article can be found on https://github.com

#javascript #algorithms #datastructures #math

JavaScript Algorithms and Data Structures: Math - Factorial
3.80 GEEK