Factorial Function
Python
Easy
2 views
Problem Description
Read one integer n. Make function fact(n) and output n!
Input Format
One integer n.
Output Format
One integer factorial.
Official Solution
import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
n=int(s)
def fact(x):
ans=1
for i in range(2,x+1):
ans*=i
return ans
sys.stdout.write(str(fact(n)))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!