Commit 27ab5a64 by Tobias Langer

There is no math.gcd in python3.

parent ad3f235b
...@@ -45,11 +45,14 @@ def query_yes_no(question, default=None): ...@@ -45,11 +45,14 @@ def query_yes_no(question, default=None):
elif 'no'.find(choice) == 0: elif 'no'.find(choice) == 0:
return False return False
def gcd(a, b):
return gcd(b, a % b)
def lcm(a, b): def lcm(a, b):
return (a * b) / math.gcd(a, b) return (a * b) / gcd(a, b)
def hyperperiod(tasks): def hyperperiod(tasks):
periods = [x.period for task in tasks] periods = [task.period for task in tasks]
hyperperiod = periods[0] hyperperiod = periods[0]
for period in periods[1:]: for period in periods[1:]:
hyperperiod = lcm(hyperperiod, period) hyperperiod = lcm(hyperperiod, period)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment