Skip to content

Commit be00bb9

Browse files
committed
-
1 parent 67a46f8 commit be00bb9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

source_py3/python_toolbox/math_tools/factorials.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ def to_factoradic(number, n_digits_pad=0):
113113
current_number = number
114114
for i in range(n_digits)[::-1]:
115115
unit = math.factorial(i)
116-
digits[n_digits - i - 1], current_number = \
117-
divmod(current_number, unit)
116+
digits[n_digits - i - 1], current_number = divmod(current_number, unit)
118117
result = tuple(digits)
119118
if (len(result) < n_digits_pad):
120119
return ((0,) * (n_digits_pad - len(result))) + result

source_py3/python_toolbox/math_tools/misc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ def restrict_number_to_range(number, low_cutoff=-infinity,
119119

120120

121121
def binomial(big, small):
122+
'''
123+
Get the binomial coefficient (big small).
124+
125+
This is used in combinatorical calculations. More information:
126+
http://en.wikipedia.org/wiki/Binomial_coefficient
127+
'''
122128
if big == small:
123129
return 1
124130
if big < small:
@@ -129,11 +135,17 @@ def binomial(big, small):
129135

130136

131137
def product(numbers):
138+
'''Get the product of all the numbers in `numbers`.'''
132139
from python_toolbox import misc_tools
133140
return misc_tools.general_product(numbers, start=1)
134141

135142

136143
def is_integer(x):
144+
'''
145+
Is `x` an integer?
146+
147+
Does return `True` for things like 1.0 and `1+0j`.
148+
'''
137149
try:
138150
inted_x = int(x)
139151
except (TypeError, ValueError, OverflowError):

0 commit comments

Comments
 (0)