# integer_partitions 函数

把一个整数写成正整数之和的所有方式。

## 怎么写

### integer_partitions(n)

**n**

一个整数。接受一个整数。

## 示例

- $\displaystyle \operatorname{integer\_partitions}(4) = \left[ \left[ 4 \right], \left[ 3, 1 \right], \left[ 2, 2 \right], \left[ 2, 1, 1 \right], \left[ 1, 1, 1, 1 \right] \right]$

  `integer_partitions(4)`

  在求解器中，`integer_partitions(4)` 的结果是 `[[4], [3, 1], [2, 2], [2, 1, 1], [1, 1, 1, 1]]`。

  [在求解器中打开](https://zh.hilberon.com/?q=integer_partitions%284%29)

## 相关函数

- [integer_exponent](https://zh.hilberon.com/library/integer_exponent)

  某个素数在一个整数中的指数。
- [factor_integer](https://zh.hilberon.com/library/factor_integer)

  整数的质因数分解，以质数和指数成对的列表给出。
- [partitions_p](https://zh.hilberon.com/library/partitions_p)

  把一个正整数写成若干正整数之和（项的次序不限）的方法数。
- [partitions_q](https://zh.hilberon.com/library/partitions_q)

  把一个正整数写成若干互不相同的正整数之和的方法数。
- [is_coprime](https://zh.hilberon.com/library/is_coprime)

  检验两个整数是否没有大于 1 的公约数。
- [is_prime](https://zh.hilberon.com/library/is_prime)

  检验一个整数是否为素数。

---
Source: https://zh.hilberon.com/library/integer_partitions
