About 3,850,000 results
Open links in new tab
  1. Factorial of a Number – Python | GeeksforGeeks

    Apr 8, 2025 · Explanation: This code defines a function factorial(n) that uses Python’s built-in math.factorial() function to calculate the factorial of a given number n. In the driver code, it calls this function with num = 5 and prints the result, which is the factorial of 5 (120).

  2. Python Program to Find the Factorial of a Number

    The factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 6 is 1*2*3*4*5*6 = 720 . Factorial is not defined for negative numbers, and the factorial of zero is one, 0! = 1 .

  3. Factorial of a Number in Python - Python Guides

    Mar 20, 2025 · This Python tutorial explains, how to print factorial of a number in Python, Python program to print factorial of a number using function, Python program to find factorial of a number using while loop, etc.

  4. factorial() in Python - GeeksforGeeks

    Jul 9, 2024 · In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.factorial() function returns the factorial of desired number. Syntax: math.factorial(x) Parameter: x: This is a numeric expression.

  5. Python program to find the factorial of a number using recursion

    Jan 31, 2023 · In this article, we are going to calculate the factorial of a number using recursion. Examples: Output: 120. Input: 6. Output: 720. Implementation: If fact (5) is called, it will call fact (4), fact (3), fact (2) and fact (1). So it means keeps calling itself by …

  6. Function for factorial in Python - Stack Overflow

    Jan 6, 2022 · The easiest way is to use math.factorial (available in Python 2.6 and above): If you want/have to write it yourself, you can use an iterative approach: fact = 1. for num in range(2, n + 1): fact *= num. return fact. or a recursive approach: if n < 2: return 1. else: return n * factorial(n-1)

  7. Factorial Program in Python using For and While Loop - The …

    Here you will get Python program to find factorial of number using for and while loop. The Factorial of a number is calculated by multiplying it with all the numbers below it starting from 1. For example, the factorial of 4 is 24 (1 x 2 x 3 x 4). The below program takes a number from the user as input and finds its factorial. fac = fac * i. Output.

  8. Factorial Program in Python: A Comprehensive Guide

    2 days ago · The factorial of a non - negative integer `n`, denoted by `n!`, is the product of all positive integers less than or equal to `n`. For example, `5! = 5 × 4 × 3 × 2 × 1 = 120`. In Python, calculating factorials is a common programming task that can be achieved through various methods. Understanding how to write a factorial program in Python not only helps in solving mathematical problems ...

  9. Python Program For Factorial (3 Methods With Code) - Python

    To write a factorial program in Python, you can define a function that uses recursion or iteration to calculate the factorial of a number. Here is an example using recursion: def factorial(n): if n == 0: return 1 else: return n * factorial(n-1)

  10. How to Find the Factorial of a Number Using Python

    Aug 16, 2024 · One of the easiest methods to find the factorial of a number is to use an in-built factorial() function in the Python math library, that directly returns the factorial of any non-negative number when applied to it:

Refresh