https://github.com/sr-murthy/continuedfractions
Object-oriented continued fractions with Python.
https://github.com/sr-murthy/continuedfractions
computational-number-theory continued-fractions coprime-number coprimes farey-sequence irrational-numbers mediants number-theory rational-approximation rational-numbers real-numbers
Last synced: 11 months ago
JSON representation
Object-oriented continued fractions with Python.
- Host: GitHub
- URL: https://github.com/sr-murthy/continuedfractions
- Owner: sr-murthy
- License: mpl-2.0
- Created: 2024-02-11T23:07:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-30T18:51:44.000Z (11 months ago)
- Last Synced: 2025-07-30T20:55:55.850Z (11 months ago)
- Topics: computational-number-theory, continued-fractions, coprime-number, coprimes, farey-sequence, irrational-numbers, mediants, number-theory, rational-approximation, rational-numbers, real-numbers
- Language: Python
- Homepage: https://continuedfractions.readthedocs.io
- Size: 3.1 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Citation: CITATION.cff
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://github.com/sr-murthy/continuedfractions/actions/workflows/ci.yml)
[](https://github.com/sr-murthy/continuedfractions/actions/workflows/codeql-analysis.yml)
[](https://codecov.io/gh/sr-murthy/continuedfractions)
[](https://github.com/astral-sh/ruff)
[](https://pdm-project.org)
[](https://opensource.org/licenses/MPL-2.0)
[](https://continuedfractions.readthedocs.io/en/latest/?badge=latest)
[](https://pypi.org/project/continuedfractions)
[](https://pepy.tech/project/continuedfractions)
# continuedfractions
A simple extension of the Python [`fractions`](https://docs.python.org/3/library/fractions.html) standard library for working with (finite, simple) [continued fractions](https://en.wikipedia.org/wiki/Continued_fraction) as Python objects.
Install from [PyPI](https://pypi.org/project/continuedfractions/):
```shell
pip install -U continuedfractions
```
or the `main` branch of this repo:
```shell
pip install -U git+https://github.com/sr-murthy/continuedfractions
```
See the [project docs](https://continuedfractions.readthedocs.io) for more details, which includes the [API reference](https://continuedfractions.readthedocs.io/sources/api-reference.html).
[Continued fractions](https://en.wikipedia.org/wiki/Continued_fraction) are beautiful and interesting mathematical objects, with many connections in [number theory](https://en.wikipedia.org/wiki/Number_theory) and also very useful practical applications, including the [rational approximation of real numbers](https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations).
The `continuedfractions` package is designed for users interested in:
* learning about and working with (finite, simple) continued fractions as Python objects, in an intuitive object-oriented way
* exploring their key properties, such as elements/coefficients, convergents, semiconvergents, remainders, and others
* operating on them as rationals and instances of the standard library [`fractions.Fraction`](https://docs.python.org/3/library/fractions.html#fractions.Fraction) class
* making approximations of and experimental computations for irrational numbers
* exploring other related objects, such as mediants, and special sequences of rational numbers such as Farey sequences
The project is [licensed](LICENSE) under the [Mozilla Public License 2.0](https://opensource.org/licenses/MPL-2.0).