Factorial calculator

Created with Sketch.

Factorial calculator

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 x 4 x 3 x 2 x 1 = 120

Here are the steps to calculate the factorial of a number:

  1. Decide on the value of n for which you want to calculate the factorial.
  2. Create a variable (e.g. “factorial”) and set its initial value to 1.
  3. Create a loop that iterates from 1 to n.
  4. Within the loop, multiply the value of “factorial” by the current loop iteration value.
  5. After the loop is completed, the value of “factorial” is the factorial of n.