Created
December 25, 2017 11:51
-
-
Save unohee/71cfdd4c4ef26de7ac3fb5055428a928 to your computer and use it in GitHub Desktop.
finding GCD in python
This file contains hidden or 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
class GCD(object): | |
def __init__(self): | |
pass | |
def gen(self, first, second): | |
self.first = first | |
self.second = second | |
if(first > second): | |
self.result() | |
x = 0 | |
while x <= first and x <= second: | |
x += 1 | |
if(first % x and second % x == 0): | |
gcd = x | |
if(second == 0): | |
gcd = first | |
# self.result() | |
return gcd | |
else: | |
return self.gen(second, first % second) | |
else: | |
print("ERROR: The First integer has to be greater than second one.") | |
pass | |
def result(self): | |
s = 'E[{0},{1}]'.format(self.first, self.second) | |
print(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment