From d5f42825f7e3e7e21822922de1120fe737041835 Mon Sep 17 00:00:00 2001 From: Shawn Ligocki Date: Fri, 22 Oct 2021 18:23:10 -0400 Subject: [PATCH] Special case 0 // n --- mod.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mod.py b/mod.py index 9c05664..157abb2 100644 --- a/mod.py +++ b/mod.py @@ -195,6 +195,10 @@ def __floordiv__(self, other): 'integer division by {}'.format(converted) ) + if self._value == 0: + # 0 // n = 0 + return Mod(0, self._modulus) + inverted = (other * self.inverse) return inverted.inverse