| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/RitikPyCode/pythonprogram/master/factorial | [Back] [Original] |
def factorial(n):
if n < 0:
return 0
elif n == 0 or n == 1:
return 1
else:
fact = 1
while(n > 1):
fact *= n
n -= 1
return fact
# Driver Code
num = 5;
print("Factorial of",num,"is",
factorial(num))
| Web Proxy Viewer | New URL | Original Page |