diff --git a/Python/program-5/README.md b/Python/program-5/README.md new file mode 100644 index 00000000..669d2d67 --- /dev/null +++ b/Python/program-5/README.md @@ -0,0 +1,7 @@ +Program 5 + +Write a program to find a factorial of a number. + +Variable description-- +fact= Holds the input number + diff --git a/Python/program-5/factorial.py b/Python/program-5/factorial.py new file mode 100644 index 00000000..9db2639b --- /dev/null +++ b/Python/program-5/factorial.py @@ -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)) \ No newline at end of file