Skip to content

Instantly share code, notes, and snippets.

@srakrn
Last active December 12, 2017 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srakrn/370f49f5f120cf554998b9758f2c141c to your computer and use it in GitHub Desktop.
Save srakrn/370f49f5f120cf554998b9758f2c141c to your computer and use it in GitHub Desktop.
A (bad) example on Python's OOP, both showing its OOP ability, and showing that not all problems needs implementation of OOP concept.
class GCDCalculator:
def __init__(self, x, y):
self.x = x
self.y = y
self.gcd = self.gcd_function(x, y)
def gcd_function(self, x, y):
while y:
x, y = y, x%y
return x
x = int(input())
y = int(input())
xy_gcd_object = GCDCalculator(x, y)
print(xy_gcd_object.gcd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment