This commit is contained in:
rzmk 2023-09-21 12:03:28 +00:00
parent 48e3274c71
commit a925f41d50
4 changed files with 246 additions and 8 deletions

View file

@ -1,2 +1,64 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Implementations of mathematical and technical concepts in Rust."><title>ladderz - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-9bb858ba049f1f21.css" id="mainThemeStyle"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ladderz" data-themes="" data-resource-suffix="" data-rustdoc-version="1.72.1 (d5c2e9c34 2023-09-13)" data-channel="1.72.1" data-search-js="search-f6292fe389d70017.js" data-settings-js="settings-de11bff964e9d4e5.js" data-settings-css="settings-8c76f75bfb6bd192.css" data-theme-light-css="light-0f8c037637f9eb3e.css" data-theme-dark-css="dark-1097f8e92a01e3cf.css" data-theme-ayu-css="ayu-614652228113ac93.css" ><script src="../static.files/storage-59fd9b8ccb335783.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-0795b7d26be81095.js"></script><noscript><link rel="stylesheet" media="(prefers-color-scheme:light)" href="../static.files/light-0f8c037637f9eb3e.css"><link rel="stylesheet" media="(prefers-color-scheme:dark)" href="../static.files/dark-1097f8e92a01e3cf.css"><link rel="stylesheet" href="../static.files/noscript-13285aec31fa243e.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="logo-container" href="../ladderz/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2></h2></nav><nav class="sidebar"><a class="logo-container" href="../ladderz/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2 class="location"><a href="#">Crate ladderz</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.1.0</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">ladderz</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/ladderz/lib.rs.html#1-4">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implementations of mathematical and technical concepts in Rust.</p> <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="ladderz"><title>ladderz - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Bold-a2c9cd1067f8b328.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-9bb858ba049f1f21.css" id="mainThemeStyle"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="ladderz" data-themes="" data-resource-suffix="" data-rustdoc-version="1.72.1 (d5c2e9c34 2023-09-13)" data-channel="1.72.1" data-search-js="search-f6292fe389d70017.js" data-settings-js="settings-de11bff964e9d4e5.js" data-settings-css="settings-8c76f75bfb6bd192.css" data-theme-light-css="light-0f8c037637f9eb3e.css" data-theme-dark-css="dark-1097f8e92a01e3cf.css" data-theme-ayu-css="ayu-614652228113ac93.css" ><script src="../static.files/storage-59fd9b8ccb335783.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-0795b7d26be81095.js"></script><noscript><link rel="stylesheet" media="(prefers-color-scheme:light)" href="../static.files/light-0f8c037637f9eb3e.css"><link rel="stylesheet" media="(prefers-color-scheme:dark)" href="../static.files/dark-1097f8e92a01e3cf.css"><link rel="stylesheet" href="../static.files/noscript-13285aec31fa243e.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="logo-container" href="../ladderz/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2></h2></nav><nav class="sidebar"><a class="logo-container" href="../ladderz/index.html"><img class="rust-logo" src="../static.files/rust-logo-151179464ae7ed46.svg" alt="logo"></a><h2 class="location"><a href="#">Crate ladderz</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.1.0</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">ladderz</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/ladderz/lib.rs.html#1-92">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="ladderz"><a href="#ladderz">ladderz</a></h2>
<p>Implementations of mathematical and technical concepts in Rust.</p>
<p>View <a href="#modules">the modules section</a> for the various implementations based on the subject.</p>
<h2 id="example"><a href="#example">Example</a></h2>
<p>Heres an example of using the <code>ladderz</code> crate to get the factors and factor pairs of a number in sorted order.
Well assume youre using Bash as your terminal.</p>
<p>First lets create a new Rust project and change into the project directory:</p>
<div class="example-wrap"><pre class="language-bash"><code>cargo new my_ladderz_project
cd my_ladderz_project
</code></pre></div>
<p>Then lets add the following to <code>Cargo.toml</code> under the <code>[dependencies]</code> section:</p>
<div class="example-wrap"><pre class="language-toml"><code>ladderz = { git = &quot;https://github.com/rzmk/ladderz&quot;, branch = &quot;main&quot; }
</code></pre></div>
<p>Now in <code>src/main.rs</code> lets replace the contents with the following code:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>ladderz::pre_algebra::unit1::{get_factor_pairs, get_factors};
<span class="kw">use </span>std::env;
<span class="kw">fn </span>main() {
<span class="comment">// Get user input as a Vec
</span><span class="kw">let </span>args: Vec&lt;String&gt; = env::args().collect();
<span class="comment">// Check if input was provided
</span><span class="kw">match </span>args.get(<span class="number">1</span>) {
<span class="prelude-val">Some</span>(<span class="kw">_</span>) =&gt; {
<span class="kw">match </span>args[<span class="number">1</span>].parse::&lt;u32&gt;() {
<span class="comment">// Handle input that can be parsed as a u32
</span><span class="prelude-val">Ok</span>(x) =&gt; {
<span class="comment">// Convert the HashSet of factors of input x to a sorted Vec
</span><span class="kw">let </span><span class="kw-2">mut </span>factors: Vec&lt;u32&gt; = get_factors(x).into_iter().collect::&lt;Vec&lt;u32&gt;&gt;();
factors.sort();
<span class="comment">// Convert the HashSet of factor pairs of input x to a sorted Vec
</span><span class="kw">let </span><span class="kw-2">mut </span>factor_pairs: Vec&lt;(u32, u32)&gt; =
get_factor_pairs(x).into_iter().collect::&lt;Vec&lt;(u32, u32)&gt;&gt;();
factor_pairs.sort();
<span class="comment">// Print the results
</span><span class="macro">println!</span>(<span class="string">&quot;List of factors of {:?}: {:?}&quot;</span>, x, factors);
<span class="macro">println!</span>(<span class="string">&quot;List of factor pairs of {:?}: {:?}&quot;</span>, x, factor_pairs);
}
<span class="comment">// Handle input that can&#39;t be parsed as a u32
</span><span class="prelude-val">Err</span>(e) =&gt; <span class="macro">println!</span>(<span class="string">&quot;Error parsing input: {e}&quot;</span>),
}
}
<span class="prelude-val">None </span>=&gt; <span class="macro">println!</span>(<span class="string">&quot;No input provided.&quot;</span>),
}
}
</code></pre></div>
<p>Now lets build the projects binary file so we can run it from the command line:</p>
<div class="example-wrap"><pre class="language-bash"><code>cargo build --release
</code></pre></div>
<p>Our runnable binary file should be located at the local path <code>./target/release/my_ladders_project</code> (or <code>./target/release/my_ladders_project.exe</code> for Windows). Lets run it with the number <code>12</code> as input:</p>
<div class="example-wrap"><pre class="language-bash"><code>./target/release/my_ladderz_project 12
</code></pre></div>
<p>If you have a <code>.exe</code> file instead, you can run it with:</p>
<div class="example-wrap"><pre class="language-bash"><code>./target/release/my_ladderz_project.exe 12
</code></pre></div>
<p>The printed output should be:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>List of factors of <span class="number">12</span>: [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">12</span>]
List of factor pairs of <span class="number">12</span>: [(<span class="number">1</span>, <span class="number">12</span>), (<span class="number">2</span>, <span class="number">6</span>), (<span class="number">3</span>, <span class="number">4</span>)]</code></pre></div>
<p>Great! Weve successfully used the <code>ladderz</code> crate to get the factors and factor pairs of a number in sorted order.</p>
</div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="pre_algebra/index.html" title="mod ladderz::pre_algebra">pre_algebra</a></div><div class="desc docblock-short">Various pre-algebra implementations including factor pairs, factors, multiples, and more.</div></li></ul></section></div></main></body></html> </div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="pre_algebra/index.html" title="mod ladderz::pre_algebra">pre_algebra</a></div><div class="desc docblock-short">Various pre-algebra implementations including factor pairs, factors, multiples, and more.</div></li></ul></section></div></main></body></html>

View file

@ -1,5 +1,5 @@
var searchIndex = JSON.parse('{\ var searchIndex = JSON.parse('{\
"ladderz":{"doc":"Implementations of mathematical and technical concepts in …","t":"AAFFFFF","n":["pre_algebra","unit1","get_factor_pairs","get_factors","get_multiples_in_range","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 <code>n</code>.","Finds all factors of a positive integer <code>n</code>.","Finds all the multiples of a positive integer <code>n</code> up to and …","Checks if a positive integer <code>x</code> is a factor of another …","Checks if a positive integer <code>x</code> is a multiple of another …"],"i":[0,0,0,0,0,0,0],"f":[0,0,[1,2],[1,[[2,[1]]]],[[1,1],[[2,[1]]]],[[1,1],3],[[1,1],3]],"c":[],"p":[[15,"u32"],[3,"HashSet"],[15,"bool"]]}\ "ladderz":{"doc":"ladderz","t":"AAFFFFF","n":["pre_algebra","unit1","get_factor_pairs","get_factors","get_multiples_in_range","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 <code>n</code>.","Finds all factors of a positive integer <code>n</code>.","Finds all the multiples of a positive integer <code>n</code> up to and …","Checks if a positive integer <code>x</code> is a factor of another …","Checks if a positive integer <code>x</code> is a multiple of another …"],"i":[0,0,0,0,0,0,0],"f":[0,0,[1,2],[1,[[2,[1]]]],[[1,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 window !== 'undefined' && window.initSearch) {window.initSearch(searchIndex)};
if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex}; if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};

View file

@ -2,7 +2,183 @@
<a href="#2" id="2">2</a> <a href="#2" id="2">2</a>
<a href="#3" id="3">3</a> <a href="#3" id="3">3</a>
<a href="#4" id="4">4</a> <a href="#4" id="4">4</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Implementations of mathematical and technical concepts in Rust. <a href="#5" id="5">5</a>
<a href="#6" id="6">6</a>
<a href="#7" id="7">7</a>
<a href="#8" id="8">8</a>
<a href="#9" id="9">9</a>
<a href="#10" id="10">10</a>
<a href="#11" id="11">11</a>
<a href="#12" id="12">12</a>
<a href="#13" id="13">13</a>
<a href="#14" id="14">14</a>
<a href="#15" id="15">15</a>
<a href="#16" id="16">16</a>
<a href="#17" id="17">17</a>
<a href="#18" id="18">18</a>
<a href="#19" id="19">19</a>
<a href="#20" id="20">20</a>
<a href="#21" id="21">21</a>
<a href="#22" id="22">22</a>
<a href="#23" id="23">23</a>
<a href="#24" id="24">24</a>
<a href="#25" id="25">25</a>
<a href="#26" id="26">26</a>
<a href="#27" id="27">27</a>
<a href="#28" id="28">28</a>
<a href="#29" id="29">29</a>
<a href="#30" id="30">30</a>
<a href="#31" id="31">31</a>
<a href="#32" id="32">32</a>
<a href="#33" id="33">33</a>
<a href="#34" id="34">34</a>
<a href="#35" id="35">35</a>
<a href="#36" id="36">36</a>
<a href="#37" id="37">37</a>
<a href="#38" id="38">38</a>
<a href="#39" id="39">39</a>
<a href="#40" id="40">40</a>
<a href="#41" id="41">41</a>
<a href="#42" id="42">42</a>
<a href="#43" id="43">43</a>
<a href="#44" id="44">44</a>
<a href="#45" id="45">45</a>
<a href="#46" id="46">46</a>
<a href="#47" id="47">47</a>
<a href="#48" id="48">48</a>
<a href="#49" id="49">49</a>
<a href="#50" id="50">50</a>
<a href="#51" id="51">51</a>
<a href="#52" id="52">52</a>
<a href="#53" id="53">53</a>
<a href="#54" id="54">54</a>
<a href="#55" id="55">55</a>
<a href="#56" id="56">56</a>
<a href="#57" id="57">57</a>
<a href="#58" id="58">58</a>
<a href="#59" id="59">59</a>
<a href="#60" id="60">60</a>
<a href="#61" id="61">61</a>
<a href="#62" id="62">62</a>
<a href="#63" id="63">63</a>
<a href="#64" id="64">64</a>
<a href="#65" id="65">65</a>
<a href="#66" id="66">66</a>
<a href="#67" id="67">67</a>
<a href="#68" id="68">68</a>
<a href="#69" id="69">69</a>
<a href="#70" id="70">70</a>
<a href="#71" id="71">71</a>
<a href="#72" id="72">72</a>
<a href="#73" id="73">73</a>
<a href="#74" id="74">74</a>
<a href="#75" id="75">75</a>
<a href="#76" id="76">76</a>
<a href="#77" id="77">77</a>
<a href="#78" id="78">78</a>
<a href="#79" id="79">79</a>
<a href="#80" id="80">80</a>
<a href="#81" id="81">81</a>
<a href="#82" id="82">82</a>
<a href="#83" id="83">83</a>
<a href="#84" id="84">84</a>
<a href="#85" id="85">85</a>
<a href="#86" id="86">86</a>
<a href="#87" id="87">87</a>
<a href="#88" id="88">88</a>
<a href="#89" id="89">89</a>
<a href="#90" id="90">90</a>
<a href="#91" id="91">91</a>
<a href="#92" id="92">92</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! # ladderz
//!
//! Implementations of mathematical and technical concepts in Rust.
//!
//! View [the modules section](#modules) for the various implementations based on the subject.
//!
//! # Example
//!
//! Here&#39;s an example of using the `ladderz` crate to get the factors and factor pairs of a number in sorted order.
//! We&#39;ll assume you&#39;re using Bash as your terminal.
//!
//! First let&#39;s create a new Rust project and change into the project directory:
//!
//! ```bash
//! cargo new my_ladderz_project
//! cd my_ladderz_project
//! ```
//!
//! Then let&#39;s add the following to `Cargo.toml` under the `[dependencies]` section:
//!
//! ```toml
//! ladderz = { git = &quot;https://github.com/rzmk/ladderz&quot;, branch = &quot;main&quot; }
//! ```
//!
//! Now in `src/main.rs` let&#39;s replace the contents with the following code:
//!
//! ```rust
//! use ladderz::pre_algebra::unit1::{get_factor_pairs, get_factors};
//! use std::env;
//!
//! fn main() {
//! // Get user input as a Vec
//! let args: Vec&lt;String&gt; = env::args().collect();
//!
//! // Check if input was provided
//! match args.get(1) {
//! Some(_) =&gt; {
//! match args[1].parse::&lt;u32&gt;() {
//! // Handle input that can be parsed as a u32
//! Ok(x) =&gt; {
//! // Convert the HashSet of factors of input x to a sorted Vec
//! let mut factors: Vec&lt;u32&gt; = get_factors(x).into_iter().collect::&lt;Vec&lt;u32&gt;&gt;();
//! factors.sort();
//!
//! // Convert the HashSet of factor pairs of input x to a sorted Vec
//! let mut factor_pairs: Vec&lt;(u32, u32)&gt; =
//! get_factor_pairs(x).into_iter().collect::&lt;Vec&lt;(u32, u32)&gt;&gt;();
//! factor_pairs.sort();
//!
//! // Print the results
//! println!(&quot;List of factors of {:?}: {:?}&quot;, x, factors);
//! println!(&quot;List of factor pairs of {:?}: {:?}&quot;, x, factor_pairs);
//! }
//! // Handle input that can&#39;t be parsed as a u32
//! Err(e) =&gt; println!(&quot;Error parsing input: {e}&quot;),
//! }
//! }
//! None =&gt; println!(&quot;No input provided.&quot;),
//! }
//! }
//!
//! ```
//!
//! Now let&#39;s build the project&#39;s binary file so we can run it from the command line:
//!
//! ```bash
//! cargo build --release
//! ```
//!
//! Our runnable binary file should be located at the local path `./target/release/my_ladders_project` (or `./target/release/my_ladders_project.exe` for Windows). Let&#39;s run it with the number `12` as input:
//!
//! ```bash
//! ./target/release/my_ladderz_project 12
//! ```
//!
//! If you have a `.exe` file instead, you can run it with:
//!
//! ```bash
//! ./target/release/my_ladderz_project.exe 12
//! ```
//!
//! The printed output should be:
//!
//! ```
//! List of factors of 12: [1, 2, 3, 4, 6, 12]
//! List of factor pairs of 12: [(1, 12), (2, 6), (3, 4)]
//! ```
//!
//! Great! We&#39;ve successfully used the `ladderz` crate to get the factors and factor pairs of a number in sorted order.
/// Various pre-algebra implementations including factor pairs, factors, multiples, and more. /// Various pre-algebra implementations including factor pairs, factors, multiples, and more.
</span><span class="kw">pub mod </span>pre_algebra; </span><span class="kw">pub mod </span>pre_algebra;

View file

@ -515,7 +515,7 @@
</span><span class="kw">pub fn </span>get_multiples_in_range(n: u32, end: u32) -&gt; HashSet&lt;u32&gt; { </span><span class="kw">pub fn </span>get_multiples_in_range(n: u32, end: u32) -&gt; HashSet&lt;u32&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>multiples: HashSet&lt;u32&gt; = HashSet::new(); <span class="kw">let </span><span class="kw-2">mut </span>multiples: HashSet&lt;u32&gt; = HashSet::new();
<span class="kw">for </span>num <span class="kw">in </span>n..end+<span class="number">1 </span>{ <span class="kw">for </span>num <span class="kw">in </span>n..end + <span class="number">1 </span>{
<span class="kw">if </span>num % n == <span class="number">0 </span>{ <span class="kw">if </span>num % n == <span class="number">0 </span>{
multiples.insert(num); multiples.insert(num);
} }
@ -556,7 +556,7 @@
<span class="macro">assert_eq!</span>(result, expected); <span class="macro">assert_eq!</span>(result, expected);
<span class="kw">let </span>result_2: bool = <span class="bool-val">false</span>; <span class="kw">let </span>result_2: bool = <span class="bool-val">false</span>;
<span class="kw">let </span>expected_2: bool = is_factor(<span class="number">3</span>, <span class="number">10</span>); <span class="kw">let </span>expected_2: bool = is_factor(<span class="number">3</span>, <span class="number">10</span>);
<span class="macro">assert_eq!</span>(result_2, expected_2); <span class="macro">assert_eq!</span>(result_2, expected_2);
} }