mirror of
https://github.com/rzmk/ladderz.git
synced 2025-12-19 06:59:25 +00:00
deploy: 325e5087b8
This commit is contained in:
parent
c202923651
commit
ec612c2642
7 changed files with 93 additions and 4 deletions
|
|
@ -1 +1 @@
|
|||
<!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="List of all items in this crate"><title>List of all items in this crate</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="../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"><!--[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">☰</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"><section><ul class="block"><li><a href="#functions">Functions</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"><h1>List of all items</h1><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="pre_algebra/fn.get_factor_pairs.html">pre_algebra::get_factor_pairs</a></li><li><a href="pre_algebra/fn.get_factors.html">pre_algebra::get_factors</a></li><li><a href="pre_algebra/fn.get_multiples_in_range.html">pre_algebra::get_multiples_in_range</a></li><li><a href="pre_algebra/fn.is_factor.html">pre_algebra::is_factor</a></li><li><a href="pre_algebra/fn.is_multiple.html">pre_algebra::is_multiple</a></li></ul></section></div></main></body></html>
|
||||
<!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="List of all items in this crate"><title>List of all items in this crate</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="../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"><!--[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">☰</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"><section><ul class="block"><li><a href="#functions">Functions</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"><h1>List of all items</h1><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="pre_algebra/fn.get_factor_pairs.html">pre_algebra::get_factor_pairs</a></li><li><a href="pre_algebra/fn.get_factors.html">pre_algebra::get_factors</a></li><li><a href="pre_algebra/fn.get_multiples_in_range.html">pre_algebra::get_multiples_in_range</a></li><li><a href="pre_algebra/fn.is_factor.html">pre_algebra::is_factor</a></li><li><a href="pre_algebra/fn.is_multiple.html">pre_algebra::is_multiple</a></li><li><a href="pre_algebra/fn.is_prime.html">pre_algebra::is_prime</a></li></ul></section></div></main></body></html>
|
||||
14
ladderz/pre_algebra/fn.is_prime.html
Normal file
14
ladderz/pre_algebra/fn.is_prime.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!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="Checks if a positive integer `n` is a prime number."><title>is_prime in ladderz::pre_algebra - 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="sidebar-items.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 fn"><!--[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">☰</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><div class="sidebar-elems"><h2><a href="index.html">In ladderz::pre_algebra</a></h2></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>Function <a href="../index.html">ladderz</a>::<wbr><a href="index.html">pre_algebra</a>::<wbr><a class="fn" href="#">is_prime</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/pre_algebra/unit1.rs.html#159-169">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub fn is_prime(n: <a class="primitive" href="https://doc.rust-lang.org/1.72.1/std/primitive.u32.html">u32</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.72.1/std/primitive.bool.html">bool</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Checks if a positive integer <code>n</code> is a prime number.</p>
|
||||
<p>A prime number is a positive integer greater than 1 that cannot
|
||||
be evenly divisible by any positive integers other than 1 and itself.</p>
|
||||
<h2 id="examples"><a href="#examples">Examples</a></h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>ladderz::pre_algebra::is_prime;
|
||||
|
||||
<span class="macro">assert!</span>(!is_prime(<span class="number">1</span>)); <span class="comment">// 1 is not a prime number
|
||||
</span><span class="macro">assert!</span>(is_prime(<span class="number">2</span>)); <span class="comment">// 2 is a prime number
|
||||
</span><span class="macro">assert!</span>(!is_prime(<span class="number">4</span>)); <span class="comment">// 4 is not a prime number
|
||||
</span><span class="macro">assert!</span>(is_prime(<span class="number">7</span>)); <span class="comment">// 7 is a prime number</span></code></pre></div>
|
||||
<h2 id="note"><a href="#note">Note</a></h2>
|
||||
<p>This function returns <code>false</code> for values of <code>n</code> less than 2 because, by definition, prime
|
||||
numbers must be greater than 1.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
|
|
@ -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.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></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.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 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["get_factor_pairs","get_factors","get_multiples_in_range","is_factor","is_multiple"]};
|
||||
window.SIDEBAR_ITEMS = {"fn":["get_factor_pairs","get_factors","get_multiples_in_range","is_factor","is_multiple","is_prime"]};
|
||||
11
ladderz/pre_algebra/unit1/fn.is_prime.html
Normal file
11
ladderz/pre_algebra/unit1/fn.is_prime.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../ladderz/pre_algebra/fn.is_prime.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../ladderz/pre_algebra/fn.is_prime.html">../../../ladderz/pre_algebra/fn.is_prime.html</a>...</p>
|
||||
<script>location.replace("../../../ladderz/pre_algebra/fn.is_prime.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
var searchIndex = JSON.parse('{\
|
||||
"ladderz":{"doc":"ladderz","t":"AFFFFF","n":["pre_algebra","get_factor_pairs","get_factors","get_multiples_in_range","is_factor","is_multiple"],"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 …","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],"f":[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":"AFFFFFF","n":["pre_algebra","get_factor_pairs","get_factors","get_multiples_in_range","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 …","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],"f":[0,[1,2],[1,[[2,[1]]]],[[1,1],[[2,[1]]]],[[1,1],3],[[1,1],3],[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};
|
||||
|
|
|
|||
|
|
@ -200,6 +200,38 @@
|
|||
<a href="#200" id="200">200</a>
|
||||
<a href="#201" id="201">201</a>
|
||||
<a href="#202" id="202">202</a>
|
||||
<a href="#203" id="203">203</a>
|
||||
<a href="#204" id="204">204</a>
|
||||
<a href="#205" id="205">205</a>
|
||||
<a href="#206" id="206">206</a>
|
||||
<a href="#207" id="207">207</a>
|
||||
<a href="#208" id="208">208</a>
|
||||
<a href="#209" id="209">209</a>
|
||||
<a href="#210" id="210">210</a>
|
||||
<a href="#211" id="211">211</a>
|
||||
<a href="#212" id="212">212</a>
|
||||
<a href="#213" id="213">213</a>
|
||||
<a href="#214" id="214">214</a>
|
||||
<a href="#215" id="215">215</a>
|
||||
<a href="#216" id="216">216</a>
|
||||
<a href="#217" id="217">217</a>
|
||||
<a href="#218" id="218">218</a>
|
||||
<a href="#219" id="219">219</a>
|
||||
<a href="#220" id="220">220</a>
|
||||
<a href="#221" id="221">221</a>
|
||||
<a href="#222" id="222">222</a>
|
||||
<a href="#223" id="223">223</a>
|
||||
<a href="#224" id="224">224</a>
|
||||
<a href="#225" id="225">225</a>
|
||||
<a href="#226" id="226">226</a>
|
||||
<a href="#227" id="227">227</a>
|
||||
<a href="#228" id="228">228</a>
|
||||
<a href="#229" id="229">229</a>
|
||||
<a href="#230" id="230">230</a>
|
||||
<a href="#231" id="231">231</a>
|
||||
<a href="#232" id="232">232</a>
|
||||
<a href="#233" id="233">233</a>
|
||||
<a href="#234" id="234">234</a>
|
||||
</pre></div><pre class="rust"><code><span class="kw">use </span>std::collections::HashSet;
|
||||
|
||||
<span class="doccomment">/// Finds all factor pairs for a positive integer `n`.
|
||||
|
|
@ -338,6 +370,38 @@
|
|||
multiples
|
||||
}
|
||||
|
||||
<span class="doccomment">/// Checks if a positive integer `n` is a prime number.
|
||||
///
|
||||
/// A prime number is a positive integer greater than 1 that cannot
|
||||
/// be evenly divisible by any positive integers other than 1 and itself.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// use ladderz::pre_algebra::is_prime;
|
||||
///
|
||||
/// assert!(!is_prime(1)); // 1 is not a prime number
|
||||
/// assert!(is_prime(2)); // 2 is a prime number
|
||||
/// assert!(!is_prime(4)); // 4 is not a prime number
|
||||
/// assert!(is_prime(7)); // 7 is a prime number
|
||||
/// ```
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// This function returns `false` for values of `n` less than 2 because, by definition, prime
|
||||
/// numbers must be greater than 1.
|
||||
</span><span class="kw">pub fn </span>is_prime(n: u32) -> bool {
|
||||
<span class="kw">if </span>n == <span class="number">1 </span>{
|
||||
<span class="kw">return </span><span class="bool-val">false</span>;
|
||||
};
|
||||
<span class="kw">for </span>num <span class="kw">in </span><span class="number">2</span>..n {
|
||||
<span class="kw">if </span>n % num == <span class="number">0 </span>{
|
||||
<span class="kw">return </span><span class="bool-val">false</span>;
|
||||
}
|
||||
}
|
||||
<span class="bool-val">true
|
||||
</span>}
|
||||
|
||||
<span class="attr">#[cfg(test)]
|
||||
</span><span class="kw">mod </span>tests {
|
||||
<span class="kw">use super</span>::<span class="kw-2">*</span>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue