forked from cool-RR/python_toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmisc.py
More file actions
26 lines (17 loc) · 625 Bytes
/
misc.py
File metadata and controls
26 lines (17 loc) · 625 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import math
from python_toolbox import math_tools
from python_toolbox import cute_iter_tools
infinity = float('inf')
class MISSING_ELEMENT:
'''blocktotodoc'''
def get_short_factorial_string(number, minus_one=False):
'''blocktotodoc'''
assert number >= 0 and \
isinstance(number, math_tools.PossiblyInfiniteIntegral)
if number == infinity:
return "float('inf')"
elif number <= 10:
return str(math.factorial(number) - int(minus_one))
else:
assert number > 10
return '%s!%s' % (number, ' - 1' if minus_one else '')