@@ -27,15 +27,6 @@ noted otherwise, all return values are floats.
2727
2828
2929==================================================== ============================================
30- **Number-theoretic functions **
31- --------------------------------------------------------------------------------------------------
32- :func: `comb(n, k) <comb> ` Number of ways to choose *k * items from *n * items without repetition and without order
33- :func: `factorial(n) <factorial> ` *n * factorial
34- :func: `gcd(*integers) <gcd> ` Greatest common divisor of the integer arguments
35- :func: `isqrt(n) <isqrt> ` Integer square root of a nonnegative integer *n *
36- :func: `lcm(*integers) <lcm> ` Least common multiple of the integer arguments
37- :func: `perm(n, k) <perm> ` Number of ways to choose *k * items from *n * items without repetition and with order
38-
3930**Floating point arithmetic **
4031--------------------------------------------------------------------------------------------------
4132:func: `ceil(x) <ceil> ` Ceiling of *x *, the smallest integer greater than or equal to *x *
@@ -126,92 +117,6 @@ noted otherwise, all return values are floats.
126117==================================================== ============================================
127118
128119
129- Number-theoretic functions
130- --------------------------
131-
132- .. function :: comb(n, k)
133-
134- Return the number of ways to choose *k * items from *n * items without repetition
135- and without order.
136-
137- Evaluates to ``n! / (k! * (n - k)!) `` when ``k <= n `` and evaluates
138- to zero when ``k > n ``.
139-
140- Also called the binomial coefficient because it is equivalent
141- to the coefficient of k-th term in polynomial expansion of
142- ``(1 + x)ⁿ ``.
143-
144- Raises :exc: `TypeError ` if either of the arguments are not integers.
145- Raises :exc: `ValueError ` if either of the arguments are negative.
146-
147- .. versionadded :: 3.8
148-
149-
150- .. function :: factorial(n)
151-
152- Return factorial of the nonnegative integer *n *.
153-
154- .. versionchanged :: 3.10
155- Floats with integral values (like ``5.0 ``) are no longer accepted.
156-
157-
158- .. function :: gcd(*integers)
159-
160- Return the greatest common divisor of the specified integer arguments.
161- If any of the arguments is nonzero, then the returned value is the largest
162- positive integer that is a divisor of all arguments. If all arguments
163- are zero, then the returned value is ``0 ``. ``gcd() `` without arguments
164- returns ``0 ``.
165-
166- .. versionadded :: 3.5
167-
168- .. versionchanged :: 3.9
169- Added support for an arbitrary number of arguments. Formerly, only two
170- arguments were supported.
171-
172-
173- .. function :: isqrt(n)
174-
175- Return the integer square root of the nonnegative integer *n *. This is the
176- floor of the exact square root of *n *, or equivalently the greatest integer
177- *a * such that *a *\ ² |nbsp | ≤ |nbsp | *n *.
178-
179- For some applications, it may be more convenient to have the least integer
180- *a * such that *n * |nbsp | ≤ |nbsp | *a *\ ², or in other words the ceiling of
181- the exact square root of *n *. For positive *n *, this can be computed using
182- ``a = 1 + isqrt(n - 1) ``.
183-
184- .. versionadded :: 3.8
185-
186-
187- .. function :: lcm(*integers)
188-
189- Return the least common multiple of the specified integer arguments.
190- If all arguments are nonzero, then the returned value is the smallest
191- positive integer that is a multiple of all arguments. If any of the arguments
192- is zero, then the returned value is ``0 ``. ``lcm() `` without arguments
193- returns ``1 ``.
194-
195- .. versionadded :: 3.9
196-
197-
198- .. function :: perm(n, k=None)
199-
200- Return the number of ways to choose *k * items from *n * items
201- without repetition and with order.
202-
203- Evaluates to ``n! / (n - k)! `` when ``k <= n `` and evaluates
204- to zero when ``k > n ``.
205-
206- If *k * is not specified or is ``None ``, then *k * defaults to *n *
207- and the function returns ``n! ``.
208-
209- Raises :exc: `TypeError ` if either of the arguments are not integers.
210- Raises :exc: `ValueError ` if either of the arguments are negative.
211-
212- .. versionadded :: 3.8
213-
214-
215120Floating point arithmetic
216121-------------------------
217122
@@ -812,6 +717,75 @@ Special functions
812717 .. versionadded :: 3.2
813718
814719
720+ Number-theoretic functions
721+ --------------------------
722+
723+ For backward compatibility, the :mod: `math ` module provides also aliases of
724+ the following functions from the :mod: `math.integer ` module:
725+
726+ .. list-table ::
727+
728+ * - .. function:: comb(n, k)
729+ :no-typesetting:
730+
731+ :func: `comb(n, k) <math.integer.comb> `
732+ - Number of ways to choose *k * items from *n * items without repetition
733+ and without order
734+
735+ * - .. function:: factorial(n)
736+ :no-typesetting:
737+
738+ :func: `factorial(n) <math.integer.factorial> `
739+ - *n * factorial
740+
741+ * - .. function:: gcd(*integers)
742+ :no-typesetting:
743+
744+ :func: `gcd(*integers) <math.integer.gcd> `
745+ - Greatest common divisor of the integer arguments
746+
747+ * - .. function:: isqrt(n)
748+ :no-typesetting:
749+
750+ :func: `isqrt(n) <math.integer.isqrt> `
751+ - Integer square root of a nonnegative integer *n *
752+
753+ * - .. function:: lcm(*integers)
754+ :no-typesetting:
755+
756+ :func: `lcm(*integers) <math.integer.lcm> `
757+ - Least common multiple of the integer arguments
758+
759+ * - .. function:: perm(n, k)
760+ :no-typesetting:
761+
762+ :func: `perm(n, k) <math.integer.perm> `
763+ - Number of ways to choose *k * items from *n * items without repetition
764+ and with order
765+
766+ .. versionadded :: 3.5
767+ The :func: `gcd ` function.
768+
769+ .. versionadded :: 3.8
770+ The :func: `comb `, :func: `perm ` and :func: `isqrt ` functions.
771+
772+ .. versionadded :: 3.9
773+ The :func: `lcm ` function.
774+
775+ .. versionchanged :: 3.9
776+ Added support for an arbitrary number of arguments in the :func: `gcd `
777+ function.
778+ Formerly, only two arguments were supported.
779+
780+ .. versionchanged :: 3.10
781+ Floats with integral values (like ``5.0 ``) are no longer accepted in the
782+ :func: `factorial ` function.
783+
784+ .. deprecated :: next
785+ These aliases are :term: `soft deprecated ` in favor of the
786+ :mod: `math.integer ` functions.
787+
788+
815789Constants
816790---------
817791
@@ -894,5 +868,5 @@ Constants
894868 Module :mod: `cmath `
895869 Complex number versions of many of these functions.
896870
897- .. | nbsp | unicode :: 0xA0
898- :trim:
871+ Module :mod: ` math.integer `
872+ Integer-specific mathematics functions.
0 commit comments