From 51817d3873721faf033267f73aacb89da7fd8780 Mon Sep 17 00:00:00 2001 From: rzmk Date: Wed, 20 Sep 2023 21:28:01 +0000 Subject: [PATCH] deploy: 186f76d4f7409a3568b17de9715d3ce67cf3f079 --- ladderz/all.html | 2 +- ladderz/index.html | 2 +- ladderz/pre_algebra/index.html | 2 +- .../unit1/fn.get_factor_pairs.html | 6 +- ladderz/pre_algebra/unit1/fn.get_factors.html | 6 +- ladderz/pre_algebra/unit1/fn.is_factor.html | 24 ++ ladderz/pre_algebra/unit1/fn.is_multiple.html | 21 ++ ladderz/pre_algebra/unit1/index.html | 4 +- ladderz/pre_algebra/unit1/sidebar-items.js | 2 +- search-index.js | 2 +- src/ladderz/lib.rs.html | 2 +- src/ladderz/pre_algebra/unit1.rs.html | 222 ++++++++++++++++-- 12 files changed, 267 insertions(+), 28 deletions(-) create mode 100644 ladderz/pre_algebra/unit1/fn.is_factor.html create mode 100644 ladderz/pre_algebra/unit1/fn.is_multiple.html diff --git a/ladderz/all.html b/ladderz/all.html index 19c61f4..cd04d4b 100644 --- a/ladderz/all.html +++ b/ladderz/all.html @@ -1 +1 @@ -List of all items in this crate
\ No newline at end of file +List of all items in this crate
\ No newline at end of file diff --git a/ladderz/index.html b/ladderz/index.html index 7fa1cd6..0596e62 100644 --- a/ladderz/index.html +++ b/ladderz/index.html @@ -1,2 +1,2 @@ ladderz - Rust

Crate ladderz

source ·
Expand description

Implementations of mathematical and technical concepts in Rust.

-

Modules

  • Various pre-algebra implementations including multiples (planned), factor pairs, etc.
\ No newline at end of file +

Modules

\ No newline at end of file diff --git a/ladderz/pre_algebra/index.html b/ladderz/pre_algebra/index.html index a29b7f0..621bc46 100644 --- a/ladderz/pre_algebra/index.html +++ b/ladderz/pre_algebra/index.html @@ -1,2 +1,2 @@ -ladderz::pre_algebra - Rust

Module ladderz::pre_algebra

source ·
Expand description

Various pre-algebra implementations including multiples (planned), factor pairs, etc.

+ladderz::pre_algebra - Rust

Module ladderz::pre_algebra

source ·
Expand description

Various pre-algebra implementations including factor pairs, factors, multiples, and more.

Modules

  • Factors and multiples
\ No newline at end of file diff --git a/ladderz/pre_algebra/unit1/fn.get_factor_pairs.html b/ladderz/pre_algebra/unit1/fn.get_factor_pairs.html index 71c17b7..3ba6fdc 100644 --- a/ladderz/pre_algebra/unit1/fn.get_factor_pairs.html +++ b/ladderz/pre_algebra/unit1/fn.get_factor_pairs.html @@ -1,8 +1,8 @@ -get_factor_pairs in ladderz::pre_algebra::unit1 - Rust
pub fn get_factor_pairs(n: u32) -> HashSet<(u32, u32)>
Expand description

Finds all factor pairs for a given positive integer.

+get_factor_pairs in ladderz::pre_algebra::unit1 - Rust
pub fn get_factor_pairs(n: u32) -> HashSet<(u32, u32)>
Expand description

Finds all factor pairs for a positive integer n.

Challenge

-

Write a program that finds all the factor pairs for a given number n.

+

Write a program that finds all the factor pairs for a number n.

Description

-

Generates a HashSet of factor pairs for a given positive integer n.

+

Generates a HashSet of factor pairs for a positive integer n.

This function calculates and returns a HashSet 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).

diff --git a/ladderz/pre_algebra/unit1/fn.get_factors.html b/ladderz/pre_algebra/unit1/fn.get_factors.html index 97f2e8a..5627f8f 100644 --- a/ladderz/pre_algebra/unit1/fn.get_factors.html +++ b/ladderz/pre_algebra/unit1/fn.get_factors.html @@ -1,8 +1,8 @@ -get_factors in ladderz::pre_algebra::unit1 - Rust
pub fn get_factors(n: u32) -> HashSet<u32>
Expand description

Finds all factors of a given positive integer.

+get_factors in ladderz::pre_algebra::unit1 - Rust
pub fn get_factors(n: u32) -> HashSet<u32>
Expand description

Finds all factors of a positive integer n.

Challenge

-

Write a program that finds all the factors of a given number. Assume that n is a positive integer greater than or equal to 1.

+

Write a program that finds all the factors of a number. Assume that n is a positive integer greater than or equal to 1.

Description

-

Generates a HashSet of factors for a given positive integer n.

+

Generates a HashSet of factors for a positive integer n.

This function calculates and returns a HashSet containing all unique factors of the input positive integer n. A factor of n is a positive integer a where n is evenly divisible by a (i.e., n % a == 0).

diff --git a/ladderz/pre_algebra/unit1/fn.is_factor.html b/ladderz/pre_algebra/unit1/fn.is_factor.html new file mode 100644 index 0000000..9b37a8c --- /dev/null +++ b/ladderz/pre_algebra/unit1/fn.is_factor.html @@ -0,0 +1,24 @@ +is_factor in ladderz::pre_algebra::unit1 - Rust
pub fn is_factor(x: u32, y: u32) -> bool
Expand description

Checks if a positive integer x is a factor of another positive integer y.

+

Challenge

+

Write a program that determines whether one positive integer is a factor of another.

+

Description

+

Checks if a positive integer x is a factor of another positive integer y.

+

A factor of y is a positive integer x where y is evenly divisible by x (i.e., y % x == 0).

+

Arguments

+
    +
  • x - The positive integer to determine whether it is a factor of y or not.
  • +
  • y - The positive integer for which the factor check of x is performed.
  • +
+

Returns

+

true if x is a factor of y, false otherwise.

+

Examples

+
use ladderz::pre_algebra::unit1::is_factor;
+
+fn main() {
+    assert!(is_factor(2, 16)); // 2 is a factor of 16
+    assert!(!is_factor(3, 16)); // 3 is not a factor of 16
+}
+

Note

+

This function determines if x is a factor of y by checking if y is evenly divisible by x +(i.e., y % x == 0).

+
\ No newline at end of file diff --git a/ladderz/pre_algebra/unit1/fn.is_multiple.html b/ladderz/pre_algebra/unit1/fn.is_multiple.html new file mode 100644 index 0000000..5a5ee73 --- /dev/null +++ b/ladderz/pre_algebra/unit1/fn.is_multiple.html @@ -0,0 +1,21 @@ +is_multiple in ladderz::pre_algebra::unit1 - Rust
pub fn is_multiple(x: u32, y: u32) -> bool
Expand description

Checks if a positive integer x is a multiple of another positive integer y.

+

Challenge

+

Write a program that determines whether one positive integer is a multiple of another.

+

Description

+

Checks if a positive integer x is a multiple of another positive integer y.

+

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

+

Arguments

+
    +
  • x - The positive integer to determine whether it is a multiple of y or not.
  • +
  • y - The positive integer for which the multiple check of x is performed.
  • +
+

Returns

+

true if x is a multiple of y, false otherwise.

+

Examples

+
use ladderz::pre_algebra::unit1::is_multiple;
+
+fn main() {
+    assert!(is_multiple(16, 2)); // 16 is a multiple of 2
+    assert!(!is_multiple(16, 3)); // 16 is not a multiple of 3
+}
+
\ No newline at end of file diff --git a/ladderz/pre_algebra/unit1/index.html b/ladderz/pre_algebra/unit1/index.html index 8c3bdc6..887ad80 100644 --- a/ladderz/pre_algebra/unit1/index.html +++ b/ladderz/pre_algebra/unit1/index.html @@ -1,2 +1,2 @@ -ladderz::pre_algebra::unit1 - Rust

Module ladderz::pre_algebra::unit1

source ·
Expand description

Factors and multiples

-

Functions

\ No newline at end of file +ladderz::pre_algebra::unit1 - Rust

Module ladderz::pre_algebra::unit1

source ·
Expand description

Factors and multiples

+

Functions

  • Finds all factor pairs for a positive integer n.
  • Finds all factors of a positive integer n.
  • Checks if a positive integer x is a factor of another positive integer y.
  • Checks if a positive integer x is a multiple of another positive integer y.
\ No newline at end of file diff --git a/ladderz/pre_algebra/unit1/sidebar-items.js b/ladderz/pre_algebra/unit1/sidebar-items.js index 7cf5ff3..9e7010f 100644 --- a/ladderz/pre_algebra/unit1/sidebar-items.js +++ b/ladderz/pre_algebra/unit1/sidebar-items.js @@ -1 +1 @@ -window.SIDEBAR_ITEMS = {"fn":["get_factor_pairs","get_factors"]}; \ No newline at end of file +window.SIDEBAR_ITEMS = {"fn":["get_factor_pairs","get_factors","is_factor","is_multiple"]}; \ No newline at end of file diff --git a/search-index.js b/search-index.js index de6c98e..7ad9bb7 100644 --- a/search-index.js +++ b/search-index.js @@ -1,5 +1,5 @@ var searchIndex = JSON.parse('{\ -"ladderz":{"doc":"Implementations of mathematical and technical concepts in …","t":"AAFF","n":["pre_algebra","unit1","get_factor_pairs","get_factors"],"q":[[0,"ladderz"],[1,"ladderz::pre_algebra"],[2,"ladderz::pre_algebra::unit1"]],"d":["Various pre-algebra implementations including multiples …","Factors and multiples","Finds all factor pairs for a given positive integer.","Finds all factors of a given positive integer."],"i":[0,0,0,0],"f":[0,0,[1,2],[1,[[2,[1]]]]],"c":[],"p":[[15,"u32"],[3,"HashSet"]]}\ +"ladderz":{"doc":"Implementations of mathematical and technical concepts in …","t":"AAFFFF","n":["pre_algebra","unit1","get_factor_pairs","get_factors","is_factor","is_multiple"],"q":[[0,"ladderz"],[1,"ladderz::pre_algebra"],[2,"ladderz::pre_algebra::unit1"]],"d":["Various pre-algebra implementations including factor …","Factors and multiples","Finds all factor pairs for a positive integer n.","Finds all factors of a positive integer n.","Checks if a positive integer x is a factor of another …","Checks if a positive integer x is a multiple of another …"],"i":[0,0,0,0,0,0],"f":[0,0,[1,2],[1,[[2,[1]]]],[[1,1],3],[[1,1],3]],"c":[],"p":[[15,"u32"],[3,"HashSet"],[15,"bool"]]}\ }'); if (typeof window !== 'undefined' && window.initSearch) {window.initSearch(searchIndex)}; if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex}; diff --git a/src/ladderz/lib.rs.html b/src/ladderz/lib.rs.html index 46282ac..48b1b0c 100644 --- a/src/ladderz/lib.rs.html +++ b/src/ladderz/lib.rs.html @@ -4,6 +4,6 @@ 4
//! Implementations of mathematical and technical concepts in Rust.
 
-/// Various pre-algebra implementations including multiples (planned), factor pairs, etc.
+/// Various pre-algebra implementations including factor pairs, factors, multiples, and more.
 pub mod pre_algebra;
 
\ No newline at end of file diff --git a/src/ladderz/pre_algebra/unit1.rs.html b/src/ladderz/pre_algebra/unit1.rs.html index b8ba17c..9ae985b 100644 --- a/src/ladderz/pre_algebra/unit1.rs.html +++ b/src/ladderz/pre_algebra/unit1.rs.html @@ -134,17 +134,114 @@ 134 135 136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233
use std::collections::HashSet;
 
-/// Finds all factor pairs for a given positive integer.
-/// 
+/// Finds all factor pairs for a positive integer `n`.
+///
 /// # Challenge
-/// 
-/// Write a program that finds all the factor pairs for a given number `n`.
-/// 
+///
+/// Write a program that finds all the factor pairs for a number `n`.
+///
 /// # Description
-/// 
-/// Generates a `HashSet` of factor pairs for a given positive integer `n`.
+///
+/// Generates a `HashSet` of factor pairs for a positive integer `n`.
 ///
 /// This function calculates and returns a `HashSet` containing all unique factor pairs
 /// of the input positive integer `n`. A factor pair is a pair of positive integers
@@ -193,15 +290,15 @@
     factor_pairs
 }
 
-/// Finds all factors of a given positive integer.
-/// 
+/// Finds all factors of a positive integer `n`.
+///
 /// # Challenge
-/// 
-/// Write a program that finds all the factors of a given number. Assume that `n` is a positive integer greater than or equal to 1.
+///
+/// Write a program that finds all the factors of a number. Assume that `n` is a positive integer greater than or equal to 1.
 ///
 /// # Description
-/// 
-/// Generates a `HashSet` of factors for a given positive integer `n`.
+///
+/// Generates a `HashSet` of factors for a positive integer `n`.
 ///
 /// This function calculates and returns a `HashSet` containing all unique factors
 /// of the input positive integer `n`. A factor of `n` is a positive integer `a` where
@@ -236,7 +333,7 @@
 pub fn get_factors(n: u32) -> HashSet<u32> {
     let mut factors: HashSet<u32> = HashSet::new();
 
-    for num in 1..n+1 {
+    for num in 1..n + 1 {
         if n % num == 0 {
             factors.insert(num);
         }
@@ -244,6 +341,81 @@
     factors
 }
 
+/// Checks if a positive integer `x` is a factor of another positive integer `y`.
+///
+/// # Challenge
+///
+/// Write a program that determines whether one positive integer is a factor of another.
+///
+/// # Description
+///
+/// Checks if a positive integer `x` is a factor of another positive integer `y`.
+///
+/// A factor of `y` is a positive integer `x` where `y` is evenly divisible by `x` (i.e., `y % x == 0`).
+///
+/// # Arguments
+///
+/// * `x` - The positive integer to determine whether it is a factor of `y` or not.
+/// * `y` - The positive integer for which the factor check of `x` is performed.
+///
+/// # Returns
+///
+/// `true` if `x` is a factor of `y`, `false` otherwise.
+///
+/// # Examples
+///
+/// ```rust
+/// use ladderz::pre_algebra::unit1::is_factor;
+///
+/// fn main() {
+///     assert!(is_factor(2, 16)); // 2 is a factor of 16
+///     assert!(!is_factor(3, 16)); // 3 is not a factor of 16
+/// }
+/// ```
+///
+/// # Note
+///
+/// This function determines if `x` is a factor of `y` by checking if `y` is evenly divisible by `x`
+/// (i.e., `y % x == 0`).
+pub fn is_factor(x: u32, y: u32) -> bool {
+    y % x == 0
+}
+
+/// Checks if a positive integer `x` is a multiple of another positive integer `y`.
+/// 
+/// # Challenge
+/// 
+/// Write a program that determines whether one positive integer is a multiple of another.
+///
+/// # Description
+/// 
+/// Checks if a positive integer `x` is a multiple of another positive integer `y`.
+///
+/// A multiple of `y` is a positive integer `x` where `x` is evenly divisible by `y` (i.e., `x % y == 0`).
+///
+/// # Arguments
+///
+/// * `x` - The positive integer to determine whether it is a multiple of `y` or not.
+/// * `y` - The positive integer for which the multiple check of `x` is performed.
+///
+/// # Returns
+///
+/// `true` if `x` is a multiple of `y`, `false` otherwise.
+///
+/// # Examples
+///
+/// ```rust
+/// use ladderz::pre_algebra::unit1::is_multiple;
+///
+/// fn main() {
+///     assert!(is_multiple(16, 2)); // 16 is a multiple of 2
+///     assert!(!is_multiple(16, 3)); // 16 is not a multiple of 3
+/// }
+/// ```
+pub fn is_multiple(x: u32, y: u32) -> bool {
+    x % y == 0
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
@@ -269,5 +441,27 @@
         let expected_2: HashSet<u32> = [1, 2, 4, 8, 16].into();
         assert_eq!(result_2, expected_2);
     }
+
+    #[test]
+    fn test_is_factor() {
+        let result: bool = true;
+        let expected: bool = is_factor(2, 10);
+        assert_eq!(result, expected);
+
+        let result_2: bool = false;
+        let expected_2: bool =  is_factor(3, 10);
+        assert_eq!(result_2, expected_2);
+    }
+
+    #[test]
+    fn test_is_multiple() {
+        let result: bool = true;
+        let expected: bool = is_multiple(10, 2);
+        assert_eq!(result, expected);
+
+        let result_2: bool = false;
+        let expected_2: bool = is_multiple(11, 2);
+        assert_eq!(result_2, expected_2);
+    }
 }
 
\ No newline at end of file