Python Program for Factorial Using Loop and Recursive Function

Factorial of n is the product of all positive descending integers. Factorial of n is denoted by n!.

Here, 4! is pronounced as “4 factorial”, it is also called “4 bang” or “4 shriek”.

The factorial is normally used in Combinations and Permutations (mathematics).

There are many ways to write the factorial program in Python language. Let’s see the 2 ways to write the factorial program in Python.

• Factorial Program using loop
• Factorial Program using recursion

Factorial Using Loop in Python

`num = int(input("Enter a number: "))fact = 1for i in range(1,num+1):fact = fact * iprint("Factorial of ",num, "is :",fact)`

Factorial Using Recursive Function in Python

`# Factorial using Recursion # StudyGyaan.comdef fact_recur(n):if n==0:return 1else:return(n*fact_recur(n-1))num = 4print("Factorial of",num,"is",fact_recur(num))`
• Home
• Python
• Python Program for Factorial Using Loop and Recursive Function
Filed under: Python