Program to find the factorial of all numbers from 1 to a given number using a while loop in Python:

 # While loop in Python - Factorial of all numbers from 1 to n

n = int(input("Enter a number: "))

i = 1

while i <= n:

    fact = 1

    j = 1

    while j <= i:

        fact *= j

        j += 1

    print("Factorial of", i, "is", fact)

    i += 1


Comments

Popular posts from this blog

Simple Python Program Code for Snake Game

Iris Flowers Classification ML Project with Code

Data exploration and scatter plot visualization in Python using Pandas and Matplotlib