Copyright | (c) 2011 Daniel Fischer |
---|---|
License | MIT |
Maintainer | Andrew Lelechenko <andrew.lelechenko@gmail.com> |
Stability | Provisional |
Portability | Non-portable (GHC extensions) |
Safe Haskell | None |
Language | Haskell2010 |
Chinese remainder theorem
Documentation
chineseRemainder :: [(Integer, Integer)] -> Maybe Integer Source #
Given a list [(r_1,m_1), ..., (r_n,m_n)]
of (residue,modulus)
pairs, chineseRemainder
calculates the solution to the simultaneous
congruences
r ≡ r_k (mod m_k)
if all moduli are positive and pairwise coprime. Otherwise
the result is Nothing
regardless of whether
a solution exists.