Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Python/program-5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Program 5

Write a program to find a factorial of a number.

Variable description--
fact= Holds the input number

14 changes: 14 additions & 0 deletions Python/program-5/factorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
fact=int(input("input any number"))
# input any number
factorial =1
#predefined factorial of 0
if fact<0:
print("factorial is not possible")
elif fact==0:
print("factorial of "+str(fact) +" is "+str(factorial))
else:
fact1=fact
while(fact>2):
fact-=1
fact1=fact1*(fact)
print("factorial is "+ str(fact1))