码迷,mamicode.com
首页 > 编程语言 > 详细

python: practice recurse function

时间:2020-03-15 09:29:22      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:nbsp   art   otherwise   kpi   tor   set   other   product   cte   

starting with a  factorial :

def      function_factorial(n):

       number=1

      for i   in   range(1,n+1):

        number *=i

       return number 

print(function_factorial( n)

use this application can acheved one number‘s factorial.

similar  recurse function also can realized one number factorial:

def  function_recurse(n):

      if  n==1:

          return 1

   return n*function_recurse(n-1)

print(function_recurse(n))

recurse function have follow  characters:

 1:in itself‘s function call itself  realize it function  performance

2:must setup a broke point ,otherwise it will enter a endless loop.

3: all recurse function can realize function loop also can do .

4:recurse productive  low efficiency,workpiece ratio inefficiency

 

python: practice recurse function

标签:nbsp   art   otherwise   kpi   tor   set   other   product   cte   

原文地址:https://www.cnblogs.com/alansuny/p/12495824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!