#!/usr/bin/env python # -*- coding:utf-8 -*-# Author:MrNineteen
#1*2*3*4*5*6*7=
def func(n, s): print(n) n +=1 s = s*n if n >=7: return s return func(n, s) r = func(1, 1) print(r)
用递归求阶乘
最新推荐文章于 2022-08-14 14:21:30 发布
#!/usr/bin/env python # -*- coding:utf-8 -*-# Author:MrNineteen
#1*2*3*4*5*6*7=
def func(n, s): print(n) n +=1 s = s*n if n >=7: return s return func(n, s) r = func(1, 1) print(r)