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
Post a Comment