Skip to main content

is_amicable

Function is_amicable 

Source
pub fn is_amicable(a: impl Into<BigInt>, b: impl Into<BigInt>) -> bool
Expand description

Are a and b an amicable pair (SymPy is_amicable)? That is, a ≠ b, both positive, and each is the sum of the proper divisors of the other: σ(a) − a = b and σ(b) − b = a.

§Examples

use symplex::ntheory::is_amicable;

assert!(is_amicable(220, 284));     // SymPy: True
assert!(is_amicable(1184, 1210));   // SymPy: True
assert!(is_amicable(2620, 2924));   // SymPy: True
assert!(!is_amicable(220, 285));    // SymPy: False
assert!(!is_amicable(6, 6));        // perfect, not amicable (SymPy: False)