#递归函数
#函数内部, a function can call itself, and this function is a recursive function.
def num (x): #第一步 return Num_a (n,1) #第二部def num_a (A, A, b): #与第二部对应, if the num_a at this time does not correspond to the function defined in the previous step, the code will error. If A==1: # (Last Judgment) because a==3, so a==1 not set up, until the a==1 to return B, the loop will end. Return b return Num_a (A-1,A*B) #此时循环结束, but the loop in the judgment is not over.
#x等于3时
#num_a (3,1)
#num_a (2,3)
#num_a (1,6)
#返回num_a (a-1,a*b) value with the above for Num_a (A, b), a is continuously reduced by 1, whereas the a*b of the definition expression is multiplied until a==1, the judgment is established, and return returns to the end.
#所以答案为num_a (1,6), a==1,b==6
#此递归函数也和循环是等价的, but he does not rely on the circular statement, but itself constantly called functions, so there will be a stack overflow problem.
Learn from Liu Junfeng's official website!
PS: I python is not plagiarism, but to learn the article >>> write is I study notes, record down convenient I later reference.
This article is from the "Twist Blog" blog, please be sure to keep this source http://mahua.blog.51cto.com/11572858/1969786
(record) Python article: six _ Function 2