Created
April 24, 2015 18:33
-
-
Save LoLei/deb8c838800e3590414d to your computer and use it in GitHub Desktop.
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 4 Beispiel 18 | |
Chinesischer Restsatz | |
""" | |
__author__ = "Lorenz Leitner" | |
__updated__ = "04-21-2015" | |
def getUserInput(): | |
num_array = [] | |
for i in range(0, 4): | |
num_array.append(input()) | |
return num_array | |
def product(modules): | |
p = 1 | |
for i in modules: | |
p *= i | |
return p | |
def main(): | |
global x | |
modules_map = map(int, getUserInput()) | |
modules = list(modules_map) | |
m = product(modules) | |
for x in range(0, m): | |
if (x % modules[0] == 1 % modules[0])\ | |
and (x % modules[1] == 2 % modules[1])\ | |
and (x % modules[2] == 0 % modules[2])\ | |
and (x % modules[3] == 3 % modules[3]): | |
break | |
print("x = %d + k * %d" % (x, m)) | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment