Skip to main content

malachite_nz/integer/factorization/
mod.rs

1// Copyright © 2026 Mikhail Hogrefe
2//
3// This file is part of Malachite.
4//
5// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
6// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
7// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.
8
9/// Implementations of [`IsPower`](malachite_base::num::factorization::traits::IsPower) and
10/// [`ExpressAsPower`](malachite_base::num::factorization::traits::ExpressAsPower), traits for
11/// testing if a number is a perfect power and, if it is, expressing it as such.
12pub mod is_power;
13/// Implementations of [`RemovePower`](malachite_base::num::factorization::traits::RemovePower) and
14/// [`RemovePowerAssign`](malachite_base::num::factorization::traits::RemovePowerAssign), traits for
15/// dividing out the largest power of a factor.
16///
17/// # remove_power
18/// ```
19/// use malachite_base::num::basic::traits::Two;
20/// use malachite_base::num::factorization::traits::RemovePower;
21/// use malachite_nz::integer::Integer;
22///
23/// let (q, k) = Integer::from(-12).remove_power(Integer::TWO);
24/// assert_eq!(q, -3);
25/// assert_eq!(k, 2);
26///
27/// // a negative factor raised to an odd power flips the sign
28/// let (q, k) = Integer::from(-8).remove_power(Integer::from(-2));
29/// assert_eq!(q, 1);
30/// assert_eq!(k, 3);
31/// ```
32///
33/// # remove_power_assign
34/// ```
35/// use malachite_base::num::basic::traits::Two;
36/// use malachite_base::num::factorization::traits::RemovePowerAssign;
37/// use malachite_nz::integer::Integer;
38///
39/// let mut x = Integer::from(-12);
40/// assert_eq!(x.remove_power_assign(Integer::TWO), 2);
41/// assert_eq!(x, -3);
42/// ```
43pub mod remove_power;