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 using four different ways.

 

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

 

 

 

 

Leave a Comment

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

Scroll to Top