mirror of
https://github.com/rzmk/ladderz.git
synced 2025-12-19 06:59:25 +00:00
deploy: 065c233986
This commit is contained in:
parent
ce80fd62b7
commit
5d5c0141d1
4 changed files with 6 additions and 6 deletions
File diff suppressed because one or more lines are too long
|
|
@ -5,4 +5,4 @@
|
|||
<span class="kw">let </span>x: u32 = <span class="number">10</span>;
|
||||
<span class="macro">println!</span>(<span class="string">"The factors of {x} are {:?}."</span>, get_factors(x));</code></pre></div>
|
||||
<div class="example-wrap"><pre class="language-console"><code>The factors of 10 are {1, 5, 2, 10}.
|
||||
</code></pre></div></div></details><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.get_factor_pairs.html" title="fn ladderz::pre_algebra::get_factor_pairs">get_factor_pairs</a></div><div class="desc docblock-short">Finds all factor pairs for a positive integer <code>n</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.get_factors.html" title="fn ladderz::pre_algebra::get_factors">get_factors</a></div><div class="desc docblock-short">Finds all factors of a positive integer <code>n</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.get_multiples_in_range.html" title="fn ladderz::pre_algebra::get_multiples_in_range">get_multiples_in_range</a></div><div class="desc docblock-short">Finds all the multiples of a positive integer <code>n</code> up to and including <code>end</code> (in the range [n, end]).</div></li><li><div class="item-name"><a class="fn" href="fn.get_prime_factorization.html" title="fn ladderz::pre_algebra::get_prime_factorization">get_prime_factorization</a></div><div class="desc docblock-short">Write a program that determines the prime factorization of a positive integer <code>n</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.get_primes_in_range.html" title="fn ladderz::pre_algebra::get_primes_in_range">get_primes_in_range</a></div><div class="desc docblock-short">Write a program that finds all prime numbers of a positive integer <code>n</code> in the range [start, n].</div></li><li><div class="item-name"><a class="fn" href="fn.is_composite.html" title="fn ladderz::pre_algebra::is_composite">is_composite</a></div><div class="desc docblock-short">Checks if a positive integer <code>n</code> is a composite number.</div></li><li><div class="item-name"><a class="fn" href="fn.is_factor.html" title="fn ladderz::pre_algebra::is_factor">is_factor</a></div><div class="desc docblock-short">Checks if a positive integer <code>x</code> is a factor of another positive integer <code>y</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.is_multiple.html" title="fn ladderz::pre_algebra::is_multiple">is_multiple</a></div><div class="desc docblock-short">Checks if a positive integer <code>x</code> is a multiple of another positive integer <code>y</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.is_prime.html" title="fn ladderz::pre_algebra::is_prime">is_prime</a></div><div class="desc docblock-short">Checks if a positive integer <code>n</code> is a prime number.</div></li></ul></section></div></main></body></html>
|
||||
</code></pre></div></div></details><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.get_factor_pairs.html" title="fn ladderz::pre_algebra::get_factor_pairs">get_factor_pairs</a></div><div class="desc docblock-short">Finds all factor pairs for a positive integer <code>n</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.get_factors.html" title="fn ladderz::pre_algebra::get_factors">get_factors</a></div><div class="desc docblock-short">Finds all factors of a positive integer <code>n</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.get_multiples_in_range.html" title="fn ladderz::pre_algebra::get_multiples_in_range">get_multiples_in_range</a></div><div class="desc docblock-short">Finds all the multiples of a positive integer <code>n</code> up to and including <code>end</code> (in the range [n, end]).</div></li><li><div class="item-name"><a class="fn" href="fn.get_prime_factorization.html" title="fn ladderz::pre_algebra::get_prime_factorization">get_prime_factorization</a></div><div class="desc docblock-short">Write a program that determines the prime factorization of a positive integer <code>n</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.get_primes_in_range.html" title="fn ladderz::pre_algebra::get_primes_in_range">get_primes_in_range</a></div><div class="desc docblock-short">Write a program that finds all prime numbers in the range [start, end] within the natural numbers.</div></li><li><div class="item-name"><a class="fn" href="fn.is_composite.html" title="fn ladderz::pre_algebra::is_composite">is_composite</a></div><div class="desc docblock-short">Checks if a positive integer <code>n</code> is a composite number.</div></li><li><div class="item-name"><a class="fn" href="fn.is_factor.html" title="fn ladderz::pre_algebra::is_factor">is_factor</a></div><div class="desc docblock-short">Checks if a positive integer <code>x</code> is a factor of another positive integer <code>y</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.is_multiple.html" title="fn ladderz::pre_algebra::is_multiple">is_multiple</a></div><div class="desc docblock-short">Checks if a positive integer <code>x</code> is a multiple of another positive integer <code>y</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.is_prime.html" title="fn ladderz::pre_algebra::is_prime">is_prime</a></div><div class="desc docblock-short">Checks if a positive integer <code>n</code> is a prime number.</div></li></ul></section></div></main></body></html>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
var searchIndex = JSON.parse('{\
|
||||
"ladderz":{"doc":"ladderz","t":"AFFFFFFFFF","n":["pre_algebra","get_factor_pairs","get_factors","get_multiples_in_range","get_prime_factorization","get_primes_in_range","is_composite","is_factor","is_multiple","is_prime"],"q":[[0,"ladderz"],[1,"ladderz::pre_algebra"]],"d":["Various pre-algebra implementations including factor …","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 …","Write a program that determines the prime factorization of …","Write a program that finds all prime numbers of a positive …","Checks if a positive integer <code>n</code> is a composite number.","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 …","Checks if a positive integer <code>n</code> is a prime number."],"i":[0,0,0,0,0,0,0,0,0,0],"f":[0,[1,2],[1,[[2,[1]]]],[[1,1],[[2,[1]]]],[1,[[3,[1,1]]]],[[1,1],[[2,[1]]]],[1,4],[[1,1],4],[[1,1],4],[1,4]],"c":[],"p":[[15,"u32"],[3,"HashSet"],[3,"HashMap"],[15,"bool"]]}\
|
||||
"ladderz":{"doc":"ladderz","t":"AFFFFFFFFF","n":["pre_algebra","get_factor_pairs","get_factors","get_multiples_in_range","get_prime_factorization","get_primes_in_range","is_composite","is_factor","is_multiple","is_prime"],"q":[[0,"ladderz"],[1,"ladderz::pre_algebra"]],"d":["Various pre-algebra implementations including factor …","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 …","Write a program that determines the prime factorization of …","Write a program that finds all prime numbers in the range […","Checks if a positive integer <code>n</code> is a composite number.","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 …","Checks if a positive integer <code>n</code> is a prime number."],"i":[0,0,0,0,0,0,0,0,0,0],"f":[0,[1,2],[1,[[2,[1]]]],[[1,1],[[2,[1]]]],[1,[[3,[1,1]]]],[[1,1],[[2,[1]]]],[1,4],[[1,1],4],[[1,1],4],[1,4]],"c":[],"p":[[15,"u32"],[3,"HashSet"],[3,"HashMap"],[15,"bool"]]}\
|
||||
}');
|
||||
if (typeof window !== 'undefined' && window.initSearch) {window.initSearch(searchIndex)};
|
||||
if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
|
||||
|
|
|
|||
|
|
@ -575,7 +575,7 @@
|
|||
<span class="bool-val">false
|
||||
</span>}
|
||||
|
||||
<span class="doccomment">/// Write a program that finds all prime numbers of a positive integer `n` in the range [start, n].
|
||||
<span class="doccomment">/// Write a program that finds all prime numbers in the range [start, end] within the natural numbers.
|
||||
///
|
||||
/// A prime number is a positive integer greater than 1 that is
|
||||
/// not evenly divisible by any positive integer other than 1 and itself.
|
||||
|
|
@ -590,10 +590,10 @@
|
|||
/// let expected: HashSet<u32> = [2, 3, 5, 7].into();
|
||||
/// assert_eq!(result, expected);
|
||||
/// ```
|
||||
</span><span class="kw">pub fn </span>get_primes_in_range(start: u32, n: u32) -> HashSet<u32> {
|
||||
</span><span class="kw">pub fn </span>get_primes_in_range(start: u32, end: u32) -> HashSet<u32> {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>primes: HashSet<u32> = HashSet::new();
|
||||
|
||||
<span class="kw">for </span>num <span class="kw">in </span>start..n + <span class="number">1 </span>{
|
||||
<span class="kw">for </span>num <span class="kw">in </span>start..end + <span class="number">1 </span>{
|
||||
<span class="kw">if </span>is_prime(num) {
|
||||
primes.insert(num);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue