diff options
author | Reinier Heeres <reinier@heeres.eu> | 2007-09-19 20:35:38 (GMT) |
---|---|---|
committer | Reinier Heeres <reinier@heeres.eu> | 2007-09-19 20:35:38 (GMT) |
commit | fe8dc6b37c63dbe4615db0d237f435ff9c2cd214 (patch) | |
tree | f9646c33e110f4b8a1dc6423a5a45de0ce8a17b5 /mathlib.py | |
parent | 22e56c98224cacb30ea792219763b01daffa31da (diff) |
Fixed factorial bug
Diffstat (limited to 'mathlib.py')
-rw-r--r-- | mathlib.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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 |