About 926,000 results
Open links in new tab
  1. 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).

  2. Factorial with a While Loop in Python - codingem.com

    To use a while loop to find the factorial of a number in Python: Ask a number input. Initialize the result to 1. Start a loop where you multiply the result by the target number. Reduce one from the target number in each iteration. End the loop once the target number reaches 1. …

  3. 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.

  4. Write factorial with while loop python - Stack Overflow

    Set up your initial value for i before the loop; use the while condition to detect when i reaches its limit; increment i inside the loop. factorial = factorial * num. num = num - 1. If you just want to get a result: math.factorial (x) While loop: num = 1. while n >= 1: num = num * n. n = n - 1. return num.

  5. Factorial of a Number – Python | GeeksforGeeks

    Apr 8, 2025 · In Python, we can calculate the factorial of a number using various methods, such as loops, recursion, built-in functions, and other approaches. Example: Simple Python program to find the factorial of a number. Explanation: This code calculates the factorial of a number n (which is 6 in this case) using a for loop.

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

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

    # Function to calculate the factorial of a number using a while loop def factorial_with_while(number): # Start with the result equal to 1 result = 1 # Loop until the number is reduced to 1 while number > 1: # Multiply the result by the current number result *= number # Decrement the number by 1 number -= 1 # Return the factorial return result ...

  8. Factorial Program in Python: Explained with Examples - Simplilearn

    Apr 12, 2025 · Factorial Program in Python Using While Loop. 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:

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

    Sep 12, 2022 · Let us look at the Python program to find the factorial of a number using While Loop. Python Program to Print the Factorial of a Number Using While Loop # accept input number from user n = int(input("Enter any number: ")) # logic to calculate the factorial of a number f = 1 while n >= 1: f *= n n -= 1 # print output print("Factorial is", f)

  10. Python Program to Find Factorial of a Number - CodesCracker

    Python Program to Find Factorial of a Number. In this article, I've created some programs in Python, that find and prints factorial of a given number by user at run-time. Here are the list of approaches used: Find Factorial of a Number using while Loop; Using for Loop; Using user-defined Function; Using Recursion; Using Class

  11. Some results have been removed
Refresh