Skip to main content

Python implementation of the Chinese Remainder algorithm

Project description

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.

History

0.2.1 (2018-05-02)

  • Fix tests.

0.2.0 (2017-12-09)

  • Better documentation with synopses and examples.

  • Add Travis-CI.

0.1.0 (2017-03-16)

  • First release on PyPI.

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.2.1.tar.gz (13.5 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: modint-0.2.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for modint-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6708e4bb6cad98fe7bfebc0594444c2597fee688f280daa3f2aaa4db14c0f974
MD5 fb42cf35fd19af29598ce56cc0ee276f
BLAKE2b-256 53b709673d7f03d15a1b5a518415c036aebd47ae0cd0fcc4dc0531568c02bc98

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