Skip to content

Commit 68def8d

Browse files
authored
Create factorial.py
1 parent 08dfcdb commit 68def8d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

factorial.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# coding: utf-8
2+
3+
class Solution:
4+
"""
5+
@param: : an integer
6+
@return: the factorial of n
7+
"""
8+
9+
def factorial(self, n):
10+
# write your code here
11+
# 偷懒做法,实际就是做竖式乘法,Python内部实现了。
12+
f = 1
13+
for i in range(2, n + 1):
14+
f *= i
15+
return str(f)
16+
17+
# medium: http://lintcode.com/zh-cn/problem/factorial/

0 commit comments

Comments
 (0)