zoukankan      html  css  js  c++  java
  • python: practice recurse function

    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

  • 相关阅读:
    hadoop 配置
    spark 学习网站和资料
    spark-submit 提交任务及参数说明
    python 浮点运算
    nginx 和 php
    clojure 语法
    编程语言
    spark
    mvn 与 pom.xml
    偏导数与偏微分
  • 原文地址:https://www.cnblogs.com/alansuny/p/12495824.html
Copyright © 2011-2022 走看看