Ask AI
Skip to main content

Factorial of a number

Function: Factorial of a number

This action calculates the factorial of a given whole number. The factorial of a non-negative integer 'n' is the product of all positive integers less than or equal to 'n'. For example, the factorial of 5 (written as 5!) is 5 � 4 � 3 � 2 � 1 = 120. The factorial of 0 is defined as 1.

Input,

  • Base (NUMBER, Required): The whole number for which you want to calculate the factorial. This number must be provided.

Output,

  • Result (NUMBER): The calculated factorial of the input number.

Execution Flow,

Real-Life Examples,

Example 1: Calculate the factorial of a small number

Imagine you need to find out how many different ways you can arrange 4 books on a shelf. This is a factorial calculation.

  • Inputs:
    • Base: 4
  • Result: The action calculates 4! (4 � 3 � 2 � 1) and stores the value 24 in the 'Result' output. You now know there are 24 ways to arrange the books.

Example 2: Handling the factorial of zero

In some mathematical formulas, you might encounter the factorial of zero.

  • Inputs:
    • Base: 0
  • Result: The action calculates 0! and stores the value 1 in the 'Result' output, as per mathematical definition.

Example 3: Calculating permutations for a competition

Suppose you have 6 participants in a race, and you want to know how many different ways they can finish in the top 6 positions. This is a factorial problem.

  • Inputs:
    • Base: 6
  • Result: The action calculates 6! (6 � 5 � 4 � 3 � 2 � 1) and stores the value 720 in the 'Result' output. This tells you there are 720 possible finishing orders for the 6 participants.