Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the recursive functions of python

Shulou Source: shulou.com Published: 2022-06-03 04:32:47 09月22日 Update

This article will explain in detail what python recursive functions are, and the editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

There are two kinds of recursive functions.

Normal recursion: call yourself, and return contains expressions. -> return n * fact (n-1)

Tail recursion: call yourself, return does not contain expressions. -> return fact_iter (num-1, num * product)

Doubt: in Liao Xuefeng's recursive function, he proposed that tail recursion can solve the stack overflow problem, but at the end of the article also said that the python interpreter did not optimize the tail recursion, any recursive function has stack overflow problem, then you use tail recursion to solve a fart stack overflow problem. First take notes here, and then solve the problem of how to enter multiple lines on the command line before practicing this problem.

This is the end of this article on "what are the recursive functions of python?". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Recursion function problem article article more expression good practical ordinary content command is in knowledge interpreter Xuefeng multi-line reference practice help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Xiaomi vpn Shulou Information MariaDB