def tri_recursion(k):
if(k>0):
result = k+tri_recursion(k-1)
print(result)
else:
result = 0
return result
def get_factorial(k):
if (k<2):
result= 1
return result
else:
result = k*get_factorial(k-1)
print(result)
答案 0 :(得分:0)
已认证的工厂计划
def get_factorial(k):
if k == 0:
return 1
else:
return k * get_factorial(k-1)
已修复的TRI_RECURSION程序
def tri_recursion(k):
if k > 0:
result = k + tri_recursion(k-1)
else:
result = 0
return result
只需使用合法的整数值调用其中一个函数,并print()
调用它们的返回值