Write a program in python: Calculate a factorial for any number using function in python

 


__Author__="Simulation-hub"
## write a function to calculate factorial of number
def factorial(n):
f=1
for i in range(2,n+1):
f*=i
return f
print("Factorial of 5 is :",factorial(5))
view raw factorial.py hosted with ❤ by GitHub
Factorial of  5 is : 120

0 Comments