Skip to main content

Recursive Functions Package

Reason this release was yanked:

munged pyproject.toml

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

Detailed documentation

Overview

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) = 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, ...
  • Function 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 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boring_math_recursive_functions-0.7.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boring_math_recursive_functions-0.7.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file boring_math_recursive_functions-0.7.0.tar.gz.

File metadata

File hashes

Hashes for boring_math_recursive_functions-0.7.0.tar.gz
Algorithm Hash digest
SHA256 c43ab189af990c99a875edecf7ea35607d5d9d12a44fceb7715e583da04f0a97
MD5 79612efb584742c9d746d70ed710aee8
BLAKE2b-256 3a7ca5c20b084b51e35dcf93afc5b00901dc69b730e91a77b2027dba6e4c36b0

See more details on using hashes here.

File details

Details for the file boring_math_recursive_functions-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for boring_math_recursive_functions-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 121f729218360d9817502f12fd59b16a0396d05b1f6817c5b8306981297adf13
MD5 5c9b3770740038796be733261c9ac494
BLAKE2b-256 a3529e46065af9efaf3df5b8cf0e3f019418ccc98619ded73a35f2f179dd6721

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page