show_recursion_tree
prints out recursion tree
Installation
pip install show_recursion_tree
Example 1
@show_recursion_tree
def factorial(n):
if n == 1:
return 1
return n * factorial(n-1)
print(factorial(5))
"""
5:120
|
4:24
|
3:6
|
2:2
|
1:1
120
"""
Example 2
from show_recursion_tree import show_recursion_tree
@show_recursion_tree
def fib(n):
if n == 1:
return 1
if n == 2:
return 1
return fib(n-2) + fib(n-1)
print(fib(5))
"""
_________5:5__________
| |
___3:2_____ ___4:3________
| | | |
1:1 2:1 2:1 ___3:2_____
| |
1:1 2:1
5
"""
Example 3
@show_recursion_tree
def f(n):
if n <= 4:
return 1
return f(n-4) + f(n-3) + f(n-2) + f(n-1)
f(7)
"""
___________________7:13______________________
| | | |
3:1 4:1 ________5:4_________ ________6:7________________
| | | | | | | |
1:1 2:1 3:1 4:1 2:1 3:1 4:1 ________5:4_________
| | | |
1:1 2:1 3:1 4:1
"""
Release files for show-recursion-tree 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| show_recursion_tree-0.0.5.tar.gz | 2.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| show_recursion_tree-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 kB
Release files / show_recursion_tree-0.0.5.tar.gz
| Download URL | show_recursion_tree-0.0.5.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7aa97c4be2ce94821fe0f543f92bd217b3e0a29fb7b6243703199fd1feb71b70
|
|
BLAKE2b-256 checksum How to use checksums |
5c45be0d875bf2b38807528a616c6b698780464bff183ea024ce3fe2a5b06678
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.0
|
Release files / show_recursion_tree-0.0.5-py3-none-any.whl
| Download URL | show_recursion_tree-0.0.5-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3213c2579fb0cf7e8c34590581591613aaca54a832498704291c819bed903e30
|
|
BLAKE2b-256 checksum How to use checksums |
eff19e7672ce58be7c7820681f4eb911be22ef6ab2ba993667e37f9811d39ece
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.0
|