标签:actor cto 阶乘 style factorial class nbsp turn res
如果一个函数在内部不调用其他函数,而是它本身的话,就是递归函数
# 函数做法 def Factorial(num): i =1 result =1 while i <= num: result *= i i +=1 return result f =Factorial(5) print(f) # 递归函数 def Factorial(num): if num >=1: result =num * Factorial(num-1) else: result =1 return result f =Factorial(5) print(f)
标签:actor cto 阶乘 style factorial class nbsp turn res
原文地址:https://www.cnblogs.com/ybw1999/p/12825940.html