Factorial of a number
Function: Factorial of a number
This function helps you calculate the factorial of a given whole number. A factorial is the product of an integer and all the integers below it. For example, the factorial of 4 (written as 4!) is 4 × 3 × 2 × 1 = 24. The factorial of 0 is defined as 1.
Input,
- Base: The whole number for which you want to calculate the factorial. This input is required.
- Type: Number
Output,
- Result: The calculated factorial value of the provided 'Base' number.
- Type: Number
Execution Flow,
Real-Life Examples,
-
Calculate the factorial of 5
- Inputs:
Base: 5
- Result: The
Resultvariable will hold the value 120 (since 5! = 5 × 4 × 3 × 2 × 1 = 120).
- Inputs:
-
Calculate the factorial of 0
- Inputs:
Base: 0
- Result: The
Resultvariable will hold the value 1 (by mathematical definition, 0! = 1).
- Inputs:
-
Calculate the factorial of 7
- Inputs:
Base: 7
- Result: The
Resultvariable will hold the value 5040 (since 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040).
- Inputs: