Factorial program in Python using 4 different Ways

Factorial program in Python using 4 different ways

Here you will know that how to make factorial program in python programming using four different ways.

 

What is factorial in python

Factorial is calculated by multiplying the number from all numbers below that number.

For example, the factorial of 5 is equal to

5 × 4 × 3 × 2 × 1 = 120.

 

 

Factorial program in Python using For Loop

Output

Enter a number: 5
The factorial of 5 is 120

 

 

Factorial program in Python using While Loop

Output 1

Enter a number: 7
The factorial is: 5040

Output 2

Enter a number: 4
The factorial is: 24

 

 

Factorial program in Python using Recursion

Output

Enter a number: 5
The factorial of 5 is 120

 

 

Factorial program in Python using Function

Output

Enter a number: 5
The factorial of 5 is 120

 

 

Check out our other Python examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top