标签:key 接受 cto ... div contain word nta ons
import
functools
sum
=
0
for
i
in
range
(
1
,
21
):
sum
=
sum
+
functools.
reduce
(
lambda
x,y: x
*
y,
range
(
1
, i
+
1
))
print
(
sum
)
import
functools
def
f(n):
if
n
=
=
1
:
return
1
else
:
return
functools.
reduce
(
lambda
x,y: x
*
y,
range
(
1
, n
+
1
))
+
f(n
-
1
)
print
(f(
20
))
def
plus(n):
if
n
=
=
1
:
return
1
else
:
return
reduce
(
lambda
x,y: x
*
y,
range
(
1
,n
+
1
))
+
plus(n
-
1
)
print
plus(
20
)
sum
=
0
x
=
1
for
i
in
range
(
1
,
21
):
x
=
x
*
i
sum
=
sum
+
x
print
(
sum
)
【Python3练习题 020】 求1+2!+3!+...+20!的和
标签:key 接受 cto ... div contain word nta ons
原文地址:https://www.cnblogs.com/jackzz/p/9125471.html