Module garoupa.algebra.cyclic.nat
Classes
class Nat (i, n)-
Expand source code
class Nat(Element): """ Usage: >>> a = Nat(1414343245,2**32) >>> b = Nat(77639,2**32) >>> b 77639 >>> ~b 4294889657 >>> a * b 1414420884 >>> a * b * ~b == a True """ def __init__(self, i, n): super().__init__(i, n) self.n = n def __mul__(self, other): return Nat((self.i + other.i) % self.n, self.n) def __repr__(self): return f"{self.i}" def __invert__(self): return Nat(self.order - self.i, self.n)Usage:
>>> a = Nat(1414343245,2**32) >>> b = Nat(77639,2**32) >>> b 77639 >>> ~b 4294889657 >>> a * b 1414420884 >>> a * b * ~b == a TrueAncestors
- Element
- abc.ABC
Inherited members