def gcd(a, *other): if hasattr(a, '__iter__') or hasattr(a, '__next__'): container = list(a) else: container = [a] + list(other) res = container[0] for b in container[1:]: res = _gcd(res, b) return res
def make_manifold(self): for f in self.filling_dict['fillings'][1]: m, l = f m = round(m) l = round(l) g = abs(_gcd(m, l)) if g != 0: m = m / g l = l / g f[0], f[1] = float(m), float(l) self.update_filling_sliders() self.push_fillings_to_manifold()
def _lcm(x, y): return (x * y) // _gcd(x, y)
def _lcm(i: int, j: int) -> int: r"""Return the least common multiple of two numbers """ if (i, j) == (0, 0): return 0 return int(i * j / _gcd(i, j))