Skip to main content

modint. Python implementation of the Chinese Remainder algorithm

Info:

This is the README file for modint.

Author:

Shlomi Fish <shlomif@cpan.org>

Copyright:

© 2018, Shlomi Fish.

Date:

2021-11-26

Version:

0.4.0

https://travis-ci.org/shlomif/modint.svg?branch=master

ModInt

https://img.shields.io/pypi/v/modint.svg https://img.shields.io/travis/shlomif/modint.svg Documentation Status Updates

Python implementation of the Chinese Remainder algorithm

Features

A usable implementation of the Chinese Remainder algorithm (see https://en.wikipedia.org/wiki/Chinese_remainder_theorem ) under the permissive MIT/Expat licence. Written because none other similarly-licensed ones could be found.

What this does is given two-or-more pairwise coprime bases integers and their corresponding moduli, it finds an integer that yields these moduli for all the bases.

Example

Here is an example:

from modint import ChineseRemainderConstructor, chinese_remainder

cr = ChineseRemainderConstructor([2, 5])
# Because 5 % 2 == 1 and 5 % 5 == 0
assert cr.rem([1, 0]) == 5
# Because 8 % 2 == 0 and 8 % 5 == 3
assert cr.rem([0, 3]) == 8

# Convenience function
assert chinese_remainder([2, 3, 7], [1, 2, 3]) == 17

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Metadata

Release files for modint 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modint 0.4.0
File Size Uploaded
modint-0.4.0.tar.gz 11.5 kB Details

Release files / modint-0.4.0.tar.gz

Download URL modint-0.4.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
86c4c2ea0fba6541922ed4e3c1d44ed817be6af602479483cad986e31aa02445
BLAKE2b-256 checksum
How to use checksums
09a6f7f8bbdb97f83829b1d8044dfd24d7c2fb1428864a0a4a6cf75406f43c59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page