Skip to content

Instantly share code, notes, and snippets.

@itsjef
Last active December 10, 2015 14:08
Show Gist options
  • Save itsjef/4445521 to your computer and use it in GitHub Desktop.
Save itsjef/4445521 to your computer and use it in GitHub Desktop.
Hàm tính tích của n số tự nhiên dương đầu tiên (n!)
#!/usr/bin/env python2.7
def factorial(n):
ans = 1
if n == 0 or n == 1:
ans = 1
elif n < 0:
ans = 'no answer'
else:
for i in range(2, n+1):
ans *= i
return ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment