# Boring Math Library - Recursive functions
The purpose of this project is to explore different ways to efficiently
implement recursive functions in Python.
* Recursive functions
* [Ackermann Function](#ackermann-s-function)
* [Fibonacci Sequences](#fibonacci-sequences)
* CLI applications
* [Ackermann CGI programs](#ackermann-cgi-scripts)
Part of the "Boring Math" PyPI **bm** namespace for mathematical hobby
projects.
* **Repositories**
* [bm.recursive-functions][1] project on *PyPI*
* [Source code][2] on *GitHub*
* **Detailed documentation**
* [Detailed API documentation][3] on *GH-Pages*
### Recursive functions
#### Ackermann's Function
* Function **ackermann_list**(m: int, n: int) -> int
* an example of a total computable function that is not primitive recursive
* becomes numerically intractable after `m=4`
* see CLI section below for mathematical definition
#### Fibonacci Sequences
* Function **fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]
* returns a *Fibonacci* sequence iterator where
* `f(0) = f0` and `f(1) = f1`
* `f(n) = f(n-1) + f(n-2)`
* yield defaults to `0, 1, 1, 2, 3, 5, 8, 13, 21, ...`
* rev_fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]
* returns a *Reverse Fibonacci* sequence iterator where
* `rf(0) = f0` and `rf(1) = f1`
* `rf(n) = rf(n-1) - rf(n-2)`
* `rf(0) = fib(-1) = 1`
* `rf(1) = fib(-2) = -1`
* `rf(2) = fib(-3) = 2`
* `rf(3) = fib(-4) = -3`
* `rf(4) = fib(-5) = 5`
* yield defaults to `1, -1, 2, -3, 5, -8, 13, -21, ...`
---
## CLI Applications
Implemented in an OS and package build tool independent way via the
project.scripts section of pyproject.toml.
### Ackermann CLI scripts
Ackermann, a student of Hilbert, discovered early examples of totally
computable functions that are not primitively recursive.
A [fairly standard][4] 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`
---
[1]: https://pypi.org/project/bm.recursive-functions/
[2]: https://github.com/grscheller/bm-recursive-functions/
[3]: https://grscheller.github.io/boring-math-docs/recursive-functions/
[4]: https://mathworld.wolfram.com/AckermannFunction.html
Raw data
{
"_id": null,
"home_page": null,
"name": "bm.recursive-functions",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "recursive, recursive functions, ackermann, fibonacci",
"author": null,
"author_email": "\"Geoffrey R. Scheller\" <geoffrey@scheller.com>",
"download_url": "https://files.pythonhosted.org/packages/49/82/24874269fe96661ca35986e8412f91a3487618bd1e2c0ee1b432bec7c04d/bm_recursive_functions-0.5.0.tar.gz",
"platform": null,
"description": "# Boring Math Library - Recursive functions\n\nThe purpose of this project is to explore different ways to efficiently\nimplement recursive functions in Python.\n\n* Recursive functions\n * [Ackermann Function](#ackermann-s-function)\n * [Fibonacci Sequences](#fibonacci-sequences)\n* CLI applications\n * [Ackermann CGI programs](#ackermann-cgi-scripts)\n\nPart of the \"Boring Math\" PyPI **bm** namespace for mathematical hobby\nprojects.\n\n* **Repositories**\n * [bm.recursive-functions][1] project on *PyPI*\n * [Source code][2] on *GitHub*\n* **Detailed documentation**\n * [Detailed API documentation][3] on *GH-Pages*\n\n### Recursive functions\n\n#### Ackermann's Function\n\n* Function **ackermann_list**(m: int, n: int) -> int\n * an example of a total computable function that is not primitive recursive\n * becomes numerically intractable after `m=4`\n * see CLI section below for mathematical definition\n\n#### Fibonacci Sequences\n\n* Function **fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]\n * returns a *Fibonacci* sequence iterator where\n * `f(0) = f0` and `f(1) = f1`\n * `f(n) = f(n-1) + f(n-2)`\n * yield defaults to `0, 1, 1, 2, 3, 5, 8, 13, 21, ...`\n\n* rev_fibonacci**(f0: int=0, f1: int=1) -> Iterator[int]\n * returns a *Reverse Fibonacci* sequence iterator where\n * `rf(0) = f0` and `rf(1) = f1`\n * `rf(n) = rf(n-1) - rf(n-2)`\n * `rf(0) = fib(-1) = 1`\n * `rf(1) = fib(-2) = -1`\n * `rf(2) = fib(-3) = 2`\n * `rf(3) = fib(-4) = -3`\n * `rf(4) = fib(-5) = 5`\n * yield defaults to `1, -1, 2, -3, 5, -8, 13, -21, ...`\n\n---\n\n## CLI Applications\n\nImplemented in an OS and package build tool independent way via the\nproject.scripts section of pyproject.toml.\n\n### Ackermann CLI scripts\n\nAckermann, a student of Hilbert, discovered early examples of totally\ncomputable functions that are not primitively recursive.\n\nA [fairly standard][4] definition of the Ackermann function is\nrecursively defined for `m,n >= 0` by\n\n```\n ackermann(0,n) = n+1\n ackermann(m,0) = ackermann(m-1,1)\n ackermann(m,n) = ackermann(m-1, ackermann(m, n-1))\n```\n\n#### CLI program **ackermann_list**\n\n* Given two non-negative integers, evaluates Ackermann's function\n* Implements the recursion via a Python array\n* **Usage:** `ackerman_list m n`\n\n---\n\n[1]: https://pypi.org/project/bm.recursive-functions/\n[2]: https://github.com/grscheller/bm-recursive-functions/\n[3]: https://grscheller.github.io/boring-math-docs/recursive-functions/\n[4]: https://mathworld.wolfram.com/AckermannFunction.html\n\n",
"bugtrack_url": null,
"license": null,
"summary": "### Boring Math Library - Recursive Functions Package",
"version": "0.5.0",
"project_urls": {
"Changelog": "https://github.com/grscheller/bm-recursive-functions/blob/main/CHANGELOG.md",
"Documentation": "https://grscheller.github.io/boring-math-docs/recursive-functions",
"Source": "https://github.com/grscheller/bm-recursive-functions"
},
"split_keywords": [
"recursive",
" recursive functions",
" ackermann",
" fibonacci"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4903a5bc364577a631a8b92b7fe21e1caa3c3c80609c401c23dab1d9d3a7ec41",
"md5": "2bea686bf85924c27cd02b539096e526",
"sha256": "1ca2fbcde5e68cc460f898c511a0131c9781594b0914258959490de40acc8e37"
},
"downloads": -1,
"filename": "bm_recursive_functions-0.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2bea686bf85924c27cd02b539096e526",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 11457,
"upload_time": "2025-01-21T05:18:27",
"upload_time_iso_8601": "2025-01-21T05:18:27.834071Z",
"url": "https://files.pythonhosted.org/packages/49/03/a5bc364577a631a8b92b7fe21e1caa3c3c80609c401c23dab1d9d3a7ec41/bm_recursive_functions-0.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "498224874269fe96661ca35986e8412f91a3487618bd1e2c0ee1b432bec7c04d",
"md5": "888965392f99193e9dceac7b65087755",
"sha256": "6d7115edaeb378b6301aa9597abfb0f16c0c81a2540c7ff2749fd127e88576ec"
},
"downloads": -1,
"filename": "bm_recursive_functions-0.5.0.tar.gz",
"has_sig": false,
"md5_digest": "888965392f99193e9dceac7b65087755",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 10057,
"upload_time": "2025-01-21T05:18:29",
"upload_time_iso_8601": "2025-01-21T05:18:29.327767Z",
"url": "https://files.pythonhosted.org/packages/49/82/24874269fe96661ca35986e8412f91a3487618bd1e2c0ee1b432bec7c04d/bm_recursive_functions-0.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-21 05:18:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "grscheller",
"github_project": "bm-recursive-functions",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "bm.recursive-functions"
}