GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • math --- 數學函式
  • cmath --- 複數的數學函式
  • 回報錯誤
  • 改進此頁面
  • 顯示原始碼
  • 顯示翻譯原始碼
  • 索引
  • 模組
  • Python
  • 3.15.2 documentation
  • Python 標準函式庫 (Standard Library)
  • 數值與數學模組

This view

  • Original page
  • New address

GeezerVison is showing python.github.io — math.integer --- integer-specific mathematics functions — Python 3.15.2 說明文件

math.integer --- integer-specific mathematics functions¶

在 3.15 版被加入.


This module provides access to the mathematical functions defined for integer arguments. These functions accept integers and objects that implement the __index__() method which is used to convert the object to an integer number.

The following functions are provided by this module. All return values are computed exactly and are integers.

math.integer.comb(n, k, /)¶

Return the number of ways to choose k items from n items without repetition and without order.

Evaluates to n! / (k! * (n - k)!) when k <= n and evaluates to zero when k > n.

Also called the binomial coefficient because it is equivalent to the coefficient of k-th term in polynomial expansion of (1 + x)ⁿ.

Raises ValueError if either of the arguments are negative.

math.integer.factorial(n, /)¶

Return factorial of the nonnegative integer n.

math.integer.gcd(*integers)¶

Return the greatest common divisor of the specified integer arguments. If any of the arguments is nonzero, then the returned value is the largest positive integer that is a divisor of all arguments. If all arguments are zero, then the returned value is 0. gcd() without arguments returns 0.

math.integer.isqrt(n, /)¶

Return the integer square root of the nonnegative integer n. This is the floor of the exact square root of n, or equivalently the greatest integer a such that a² ≤ n.

For some applications, it may be more convenient to have the least integer a such that n ≤ a², or in other words the ceiling of the exact square root of n. For positive n, this can be computed using a = 1 + isqrt(n - 1).

math.integer.lcm(*integers)¶

Return the least common multiple of the specified integer arguments. If all arguments are nonzero, then the returned value is the smallest positive integer that is a multiple of all arguments. If any of the arguments is zero, then the returned value is 0. lcm() without arguments returns 1.

math.integer.perm(n, k=None, /)¶

Return the number of ways to choose k items from n items without repetition and with order.

Evaluates to n! / (n - k)! when k <= n and evaluates to zero when k > n.

If k is not specified or is None, then k defaults to n and the function returns n!.

Raises ValueError if either of the arguments are negative.

© 版權所有 2001 Python Software Foundation.
此頁面採用 Python 軟體基金會授權條款第 2 版。
文件中的範例、應用技巧與其他程式碼額外採用了 Zero Clause BSD 授權條款。
更多訊息請見歷史與授權條款。

Python 軟體基金會是一家非營利法人。 敬請捐贈。

最後更新於 11月 11, 2026 (06:44 UTC)。 發現 bug?
以 Sphinx8.2.3建立。
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.