About 632,000 results
Open links in new tab
  1. Factorial with a While Loop in Python - codingem.com

    To find factorial using a while loop in Python, multiply the result (starting at 1) by the number - 1 in a loop until the number reaches 1.

  2. Write factorial with while loop python - Stack Overflow

    Does anybody know how you can write a factorial in a while loop? I can make it in an if / elif else statement: num = ... print("must be positive") print("factorial = 1") for i in range(1,num + 1): factorial = factorial*i. print(num, factorial) But I want to do this with a while loop (no function). A for loop can be rewritten as a while loop.

  3. Factorial Program in Python using For and While Loop

    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.

  4. Factorial of a Number - Python - GeeksforGeeks

    Apr 8, 2025 · The factorial of a number is the product of all positive integers less than or equal to that number. For example, the factorial of 5 (denoted as 5!) is 5 × 4 × 3 × 2 × 1 = 120. In Python, we can calculate the factorial of a number using various methods, such as loops, recursion, built-in functions, and other approaches.

  5. Python Program to Find the Factorial of a Number

    Here, the number whose factorial is to be found is stored in num, and we check if the number is negative, zero or positive using if...elif...else statement. If the number is positive, we use for loop and range () function to calculate the factorial.

  6. Factorial of a Number in Python Using While Loop - Newtum

    Sep 12, 2022 · In Python, you can calculate the factorial using a while loop. Here are some key applications of factorials, along with an example code snippet for calculating factorials using a while loop.

  7. Factorial Program in Python: Explained with Examples

    Apr 12, 2025 · A Python program for calculating factorials using a `while` loop multiplies the numbers from 1 to the given input and accumulates their product iteratively. Example: def factorial (n): result = 1 while n > 0: result *= n n -= 1 return result # Example usage: number = 5 result = factorial (number) print (f"The factorial of {number} is {result}")

  8. Python Program to Find Factorial of a Number Using While Loop

    Dec 27, 2022 · Python Program to find Factorial of a Number is used to calculate the factorial of a given number using While loop and prints the value in the output screen.

  9. Find Factorial of any Number Using While Loop in Python

    Here is code to find the factorial of a given number using a while loop in Python: fact *= num. num -= 1. # multiply the factorial variable by the current number. fact *= num. # decrement the current number by 1. num -= 1.

  10. Factorial Program in Python (Factorial of a Number in Python)

    Oct 19, 2024 · Learn to write a factorial program in Python using for loops, while loops, recursion, and functions with code examples, detailed explanations and use cases. The factorial of a number is an essential concept in mathematics and programming. It is denoted as n!, which represents the product of all positive integers from 1 to n.

Refresh