- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Find the Factorial of a Number using Python?
Factorial of a number is the product of all integers between 1 and itself. To find factorial of a given number, let us form a for loop over a range from 1 to itself. Remember that range() function excludes the stop value. Hence stop value should be one more than the input number.
Each number in range is cumulatively multiplied in a variable f which is initialised to 1
num=int(input('enter a number')) f=1 for i in range(1,num+1): f=f*i print ('factorial of', num, '=',f)
Sample run of above code −
enter a number5 factorial of 5 = 120
- How to Find Factorial of Number Using Recursion in Python?
- Python program to find factorial of a large number
- Python Program to find the factorial of a number without recursion
- C++ Program to Find Factorial of a Number using Iteration
- C++ Program to Find Factorial of a Number using Recursion
- Java Program to Find Factorial of a Number Using Recursion
- How to find the Factorial of a number in Golang?
- Java program to find the factorial of a given number using recursion
- C++ Program to Find Factorial of a Number using Dynamic Programming
- Find the factorial of a number in pl/sql using C++.
- Write a Golang program to find the factorial of a given number (Using Recursion)
- 8085 program to find the factorial of a number
- 8086 program to find the factorial of a number
- Swift Program to Find Factorial of a number
- Java Program to Find Factorial of a number