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

Project 01: Python Code for Music Recommendation with Explanation

Iris Flowers Classification ML Project with Code