Created
April 21, 2015 20:27
-
-
Save LoLei/1de25cf9b8513832c39b to your computer and use it in GitHub Desktop.
Chinese Remainder Theorem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# coding=utf-8 | |
""" | |
Diskrete Mathematik ÜB 14 Beispiel 18 | |
Chinesischer Restsatz | |
""" | |
__author__ = "Lorenz Leitner" | |
__updated__ = "04-21-2015" | |
def product(modules): | |
p = 1 | |
for i in modules: | |
p *= i | |
return p | |
modules = (5, 7, 8, 11) | |
m = product(modules) | |
for x in range(0, m): | |
if (x % 5 == 1 % 5)\ | |
and (x % 7 == 2 % 7)\ | |
and (x % 8 == 0 % 8)\ | |
and (x % 11 == 3 % 11): | |
break | |
print("x =", x, "+ k *", m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment