# get_factor_pairs in ladderz::pre_algebra - Rust
Finds all factor pairs for a positive integer `n`.

# Function ladderz::pre_algebra::get_factor_pairs

source ·

    pub fn get_factor_pairs(n: u32) -> HashSet<(u32, u32)>

Expand description

Finds all factor pairs for a positive integer `n`.

This function calculates and returns a `HashSet<(u32, u32)>` containing all unique factor pairs of the input positive integer `n`. A factor pair is a pair of positive integers `(a, b)` where `a` and `b` are both factors of `n` (i.e., `a * b == n`).

## Examples

    use std::collections::HashSet;
    use ladderz::pre_algebra::get_factor_pairs;

    fn main() {
        let result_pairs = get_factor_pairs(12);
        let expected_pairs: HashSet<(u32, u32)> = [(1, 12), (2, 6), (3, 4)].into();
        assert_eq!(result_pairs, expected_pairs);
    }

## Note

This function calculates factor pairs by iterating through positive integers from 1 to `n` (inclusive) and checking if they divide `n` evenly. If they do, a factor pair `(a, b)` is added to the `HashSet`. The function ensures that factor pairs are unique, so `(a, b)` and `(b, a)` will not both appear in the set.