Recursive Functions Package
Project description
Boring Math Library - Recursive functions
The purpose of this project is to explore different ways to efficiently implement recursive functions in Python.
Repos and Documentation
Repositories
- boring-math.recursive-functions project on PyPI
- Source code on GitHub
Detailed documentation
- Detailed API documentation on GH-Pages
Overview
- Recursive functions
- CLI applications
This project is part of the Boring Math boring-math namespace project.
Recursive functions
Computable recursive functions can be defined with previously defined or not yet defined values. Functions defined using previously defined values having "base cases" are called "primitively recursive functions." Not all computable functions are primitively recursive.
Ackermann's Function
- Function ackermann_list(m: int, n: int) -> int
- is a total computable function that is not primitive recursive
- becomes numerically intractable after
m=4 - see CLI section below for a mathematical definition
Fibonacci Sequences
-
Function fibonacci(f0: int=0, f1: int=1) -> Iterator[int]
- returns a Fibonacci sequence iterator where
f(0) = f0andf(1) = f1f(n) = f(n-1) + f(n-2)
- yield defaults to
0, 1, 1, 2, 3, 5, 8, 13, 21, ...
- returns a Fibonacci sequence iterator where
-
Function rev_fibonacci(f0: int=0, f1: int=1) -> Iterator[int]
- returns a Reverse Fibonacci sequence iterator where
rf(0) = f0andrf(1) = f1rf(n) = rf(n-1) - rf(n-2)rf(0) = fib(-1) = 1rf(1) = fib(-2) = -1rf(2) = fib(-3) = 2rf(3) = fib(-4) = -3rf(4) = fib(-5) = 5
- yield defaults to
1, -1, 2, -3, 5, -8, 13, -21, ...
- returns a Reverse Fibonacci sequence iterator where
CLI Applications
Implemented in an OS and package build tool independent way via the project.scripts section of pyproject.toml.
Ackermann CLI programs
Ackermann, a student of Hilbert, discovered early examples of totally computable functions that are not primitively recursive.
A fairly standard definition of the Ackermann function is
recursively defined for m,n >= 0 by
ackermann(0,n) = n+1
ackermann(m,0) = ackermann(m-1,1)
ackermann(m,n) = ackermann(m-1, ackermann(m, n-1))
CLI program ackermann_list
- Given two non-negative integers, evaluates Ackermann's function
- Implements the recursion via a Python array
- Usage:
ackerman_list m n
Project details
Release history Release notifications | RSS feed
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 boring_math_recursive_functions-0.7.1.tar.gz.
File metadata
- Download URL: boring_math_recursive_functions-0.7.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85733652317d1876b17409feec1b177e72535cbe1ed55549193fcc1ecfe23b9c
|
|
| MD5 |
671c7722a81abebdd4e1e4b4c2f93210
|
|
| BLAKE2b-256 |
814d7b64922155319f0dbd05321ccc3d1b75f93277abbe2f3488833b48eba318
|
File details
Details for the file boring_math_recursive_functions-0.7.1-py3-none-any.whl.
File metadata
- Download URL: boring_math_recursive_functions-0.7.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7158dba8f7803e1edc07a366e5b920beb095e6e974e74729409113104956297
|
|
| MD5 |
2fc4b214fc4c2d22542e0a7052409910
|
|
| BLAKE2b-256 |
a4544435bfa1b7f15ff05a575bc8bd0b85720d236ac43623f0140c4dbf77c87e
|