diff --git a/plugins/Math/plugin.py b/plugins/Math/plugin.py index 518d21c7b..6b8a6342b 100644 --- a/plugins/Math/plugin.py +++ b/plugins/Math/plugin.py @@ -110,13 +110,18 @@ class Math(callbacks.Plugin): return math.sqrt(x) def _cbrt(x): return math.pow(x, 1.0/3) + def _factorial(x): + if x<=10000: + return math.factorial(x) + else: + raise Exception('factorial argument too large') _mathEnv['sqrt'] = _sqrt _mathEnv['cbrt'] = _cbrt _mathEnv['abs'] = abs _mathEnv['max'] = max _mathEnv['min'] = min - _mathSafeEnv = dict([(x,y) for x,y in _mathEnv.items() - if x not in ['factorial']]) + _mathSafeEnv = dict([(x,y) for x,y in _mathEnv.items()]) + _mathSafeEnv['factorial'] = _factorial _mathRe = re.compile(r'((?:(?