Computer Science, asked by deekshamehra2005, 1 month ago

write a python program to print the factorial of any number using while loop ?
pls don't spam​

Answers

Answered by KING777777777
7

#Python program find factorial of a number

#using while loop

num=int(input("Enter a number to find factorial: "))

#takes input from user

factorial=1; #declare and initialize factorial variable to one

#check if the number is negetive ,positive or zero

if num<0:

print("Factorial does not defined for negative integer");

elif(num==0):

print("The factorial of 0 is 1");

else:

while(num>0):

factorial=factorial*num

num=num-1

print("factorial of the given number is: ")

print(factorial)

I'm saying it truth it's by the help of my textbook as well as from Chrome I'm sorry for that .

hope the answer helps you

Answered by XxitzurshehzadixX
5

Using While Loop

num = int(input("enter a number: "))

fac = 1.

i = 1.

while i <= num:

fac = fac * i.

i = i + 1.

print("factorial of ", num, " is ", fac)

Similar questions
Math, 9 months ago