About 604,000 results
Open links in new tab
  1. Python: Using def in a factorial program - Stack Overflow

    def factorial(n): # Define a function and passing a parameter fact = 1 # Declare a variable fact and set the initial value=1 for i in range(1,n+1,1): # Using loop for iteration fact = fact*i print(fact) # …

  2. 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): import math math.factorial(1000) If you want/have to write it yourself, you can use an iterative …

  3. Factorial of a Number – Python | GeeksforGeeks

    Apr 8, 2025 · import math def factorial (n): return (math. factorial (n)) # Driver Code num = 5 print (factorial (num)) Explanation: This code defines a function factorial(n) that uses Python's built …

  4. factorial() in Python - GeeksforGeeks

    Jul 9, 2024 · Naive method to compute factorial. Using math.factorial () This method is defined in "math" module of python. Because it has C type internal implementation, it is fast. x : The …

  5. Python Program to Find the Factorial of a Number

    Factorial of a Number using Recursion # Python program to find the factorial of a number provided by the user # using recursion def factorial(x): """This is a recursive function to find the …

  6. 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 == …

  7. Factorial Function in Python: A Comprehensive Guide

    Mar 23, 2025 · In Python, implementing the factorial function is straightforward, and it serves as a great starting point for understanding more complex algorithms and mathematical …

  8. Factorial of a Number in Python - Python Guides

    Mar 20, 2025 · In this comprehensive guide, I’ll walk you through multiple approaches to calculating the factorial of a number in Python, from the simplest implementations to highly …

  9. Python Programs to Find Factorial of a Number - PYnative

    Mar 31, 2025 · This article covers several ways to find the factorial of a number in Python with examples, ranging from traditional iterative techniques to more concise recursive …

  10. Factorial Program in Python - ScholarHat

    Nov 25, 2024 · In this Python Tutorial, we’ll explore various methods to write a factorial program in Python using for loop, while loop, recursion, and functions. We will also discuss h ow to write a …

Refresh