Definition: Number of different possible ways we can arrange a set of elements.
Ex. You haven't watched the F1 race, but your friend spoiled who the top 3 racers are. [Lewis, Max, Kimi]
P (3) --> the total number of different ways these drivers could split the medal)
if (Lewis won the race) {
{1st: Lewis, 2nd: Max, 3rd: Kimi} || {1st: Lewis, 2nd: Kimi, 3rd: Max};
if (Lewis won the race) {
{2nd: Kimi, 3rd: Lewis} || {2nd: Lewis, 3rd: Kimi};
if (Lewis won the race) {
{2nd: Max, 3rd: Lewis} || {2nd: Lewis, 3rd: Max};
Six(permutation) unique ways the 3 drivers can split the medals.
Intuition --> n many elements
Gold (n) Silver(n-1) Bronze(n-2) ... 1
n = different possible winners (this case it is '3')
Pₙ = n * (n-1) * (n-2) * ... * 1 = n!
Defintion: n! --> the product of the natural numbers from 1 ton.
n! --> 1 * 2 * 3 * ... * n
3! --> 1 * 2 * 3 = 6
Important Properties for factorials
Odd Characteristics:
1. Negative numbers don't have a factorial
2. 0! === 1
n! = (n - 1)! * n
(n + 1)! = n! * (n + 1)
if (n = 6)
6! = 5 * 6
7! = 6! * 7
could be extpanded further to express
(n + k)! and (n - k)!
a. (n + k)! = n! * (n + 1) * (n + 2) * ... * (n * k)
b. (n - k)! = n! / (n - k + 1) * (n - k + 2) * ... * (n - k + k) or n
if (n = 5 && k = 2) {
a. 7! = 5! * 6 * 7
b. 3! = 5! / 4 * 5
Two factorials
if (n > k) {
n! / k! = (k + 1) * (k + 2) * ... * n
if (n = 7 && k = 4) {
7! / 4! = 5 * 6 * 7 = "1 * 2 * 3 * 4 * 5 * 6 * 7 / 1 * 2 * 3 * 4"
Be located in the folder you are working on and type in terminal
npm install --> this will install needed modules
Check for errors, type in terminal
npm run test --> this will run for test and check for errors
For submitting task to connected repository in Github,
npm run submit --> this will submit your assignment or project to repository
This is vital knowledge when using CLI to control your program.