Skip to content

Instantly share code, notes, and snippets.

@unohee
Created December 25, 2017 11:51
Show Gist options
  • Save unohee/71cfdd4c4ef26de7ac3fb5055428a928 to your computer and use it in GitHub Desktop.
Save unohee/71cfdd4c4ef26de7ac3fb5055428a928 to your computer and use it in GitHub Desktop.
finding GCD in python
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