Skip to main content

Python implementation of the Chinese Remainder algorithm

Project description

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.

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

modint-0.4.0.tar.gz (11.5 kB view details)

Uploaded Source

File details

Details for the file modint-0.4.0.tar.gz.

File metadata

  • Download URL: modint-0.4.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for modint-0.4.0.tar.gz
Algorithm Hash digest
SHA256 86c4c2ea0fba6541922ed4e3c1d44ed817be6af602479483cad986e31aa02445
MD5 1e75b0c39ce5af8b7248c1aefd396dc5
BLAKE2b-256 09a6f7f8bbdb97f83829b1d8044dfd24d7c2fb1428864a0a4a6cf75406f43c59

See more details on using hashes here.

Supported by

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