# Function ladderz::pre_algebra::unit1::get_multiples_in_range

source ·

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

Expand description

Finds all the multiples of a positive integer `n` up to and including `end` (in the range [n, end]).

## Challenge

Write a program that finds all the multiples of a positive integer `n` in a given range.

## Description

Returns a HashSet containing all the multiples of a positive integer `n` in the range [n, end].

A multiple of `n` is a positive integer `num` where `num` is evenly divisible by `n` (i.e., `num % n == 0`).

## Arguments

- `n` - The positive integer for which multiples are to be found.
- `end` - The upper limit of the range for finding multiples.

## Returns

A HashSet containing all the multiples of `n` in the range [n, end].

## Examples

    use ladderz::pre_algebra::unit1::get_multiples_in_range;
    use std::collections::HashSet;

    fn main() {
        let result: HashSet<u32> = get_multiples_in_range(2, 10);
        let expected: HashSet<u32> = [2, 4, 6, 8, 10].into();
        assert_eq!(result, expected);

        let result: HashSet<u32> = get_multiples_in_range(3, 15);
        let expected: HashSet<u32> = [3, 6, 9, 12, 15].into();
        assert_eq!(result, expected);
    }