Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/mathlib.py
diff options
context:
space:
mode:
authorReinier Heeres <reinier@heeres.eu>2007-09-19 20:35:38 (GMT)
committer Reinier Heeres <reinier@heeres.eu>2007-09-19 20:35:38 (GMT)
commitfe8dc6b37c63dbe4615db0d237f435ff9c2cd214 (patch)
treef9646c33e110f4b8a1dc6423a5a45de0ce8a17b5 /mathlib.py
parent22e56c98224cacb30ea792219763b01daffa31da (diff)
Fixed factorial bug
Diffstat (limited to 'mathlib.py')
-rw-r--r--mathlib.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/mathlib.py b/mathlib.py
index e9dffb9..4d98ad8 100644
--- a/mathlib.py
+++ b/mathlib.py
@@ -137,7 +137,7 @@ class MathLib:
def is_int(self, n):
(sign, d, e) = n.normalize().as_tuple()
- return e == 0
+ return e >= 0
def is_float(self, n):
if isinstance(n, Decimal):
@@ -206,6 +206,9 @@ class MathLib:
if not self.is_int(n):
return self.d(0)
+ if n == 0:
+ return 1
+
res = n
while n > 2:
res *= n - 1