This commit is contained in:
parent
9f75e71c3e
commit
c05cd4986e
1 changed files with 2 additions and 0 deletions
2
modp.py
2
modp.py
|
@ -11,6 +11,8 @@ class ModP(int):
|
||||||
return "%d %% %d" % (self, self.p)
|
return "%d %% %d" % (self, self.p)
|
||||||
|
|
||||||
# arithmetic
|
# arithmetic
|
||||||
|
def __neg__(self):
|
||||||
|
return ModP(self.p, self.p - int(self))
|
||||||
def __add__(self, other):
|
def __add__(self, other):
|
||||||
return ModP(self.p, int(self) + int(other))
|
return ModP(self.p, int(self) + int(other))
|
||||||
def __radd__(self, other):
|
def __radd__(self, other):
|
||||||
|
|
Loading…
Reference in a new issue