1.

Program to find factorial using for loop in python

Answer»

Explanation:

#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)



Discussion

No Comment Found