Python Armstrong NumberPython Average of N NumbersPython Biggest of Three NumbersPython Common DivisorsPython Composite NumberPython Condense a NumberPython Even NumberPython Factorial of a NumberPython Fibonacci SeriesPython GCDPython LCMPython Leap YearPython Multiplication TablePython Number CombinationPython Odd NumberPython Palindrome NumberPython Perfect NumberPython Prime FactorPython Prime NumberPython Sum of DigitsPython Swapping Two Numbers

Python Array ProgramsPython Converter ProgramsPython Star Patterns ProgramPython Number Patterns ProgramPython Alphabet Patterns ProgramLast Updated:

The factorial of a number n can be defined as the product of all positive numbers less than or equal to n. For example, the factorial of 6 is 1 × 2 × 3 × 4 × 5 × 6 = 720.

The following table provides few examples of factorial of a number.

Number | Factorial | Result |
---|---|---|

1! | 1 | 1 |

2! | 1 × 2 | 2 |

3! | 1 × 2 × 3 | 6 |

4! | 1 × 2 × 3 × 4 | 24 |

**Note**: In Mathematics, factorial of a number is represented by exclamation mark.

**Tips**: It is recommended to use our online Factorial of a Number calculator for better understanding.

In the following example, we will find a factorial of a number 6.

Python Compiler

num = 6;
i = 1;
factorial = 1;
for i in range(1, num+1):
factorial *= i;
if(num):
print("Factorial of %d: %d" % (num, factorial))
else:
print("Factorial of 0: 0");

In the following example, we will find a factorial of any given number.

Python Compiler

num = int(input("Enter a number: "));
i = 1;
factorial = 1;
for i in range(1, num+1):
factorial *= i;
if(num):
print("Factorial of %d: %d" % (num, factorial))
else:
print("Factorial of 0: 0");