print recursion trees in terminal
Project description
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
"""
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file show_recursion_tree-0.0.5.tar.gz.
File metadata
- Download URL: show_recursion_tree-0.0.5.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aa97c4be2ce94821fe0f543f92bd217b3e0a29fb7b6243703199fd1feb71b70
|
|
| MD5 |
3994fb7d5a46168464e09e28b31830b1
|
|
| BLAKE2b-256 |
5c45be0d875bf2b38807528a616c6b698780464bff183ea024ce3fe2a5b06678
|
File details
Details for the file show_recursion_tree-0.0.5-py3-none-any.whl.
File metadata
- Download URL: show_recursion_tree-0.0.5-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3213c2579fb0cf7e8c34590581591613aaca54a832498704291c819bed903e30
|
|
| MD5 |
2c038870aec6a291391b61cfaa79dc5c
|
|
| BLAKE2b-256 |
eff19e7672ce58be7c7820681f4eb911be22ef6ab2ba993667e37f9811d39ece
|