From 1e5eef1394e6c66ef1636b193d787db3e2abc708 Mon Sep 17 00:00:00 2001 From: rzmk Date: Fri, 22 Sep 2023 15:03:26 +0000 Subject: [PATCH] deploy: 1ad53495e8d319f559f2ecc2bb8f8fc22a4fa724 --- ladderz/all.html | 2 +- ladderz/pre_algebra/fn.is_composite.html | 11 +++ ladderz/pre_algebra/fn.is_prime.html | 4 +- ladderz/pre_algebra/index.html | 2 +- ladderz/pre_algebra/sidebar-items.js | 2 +- .../pre_algebra/unit1/fn.is_composite.html | 11 +++ search-index.js | 2 +- src/ladderz/pre_algebra/unit1.rs.html | 74 ++++++++++++++++++- 8 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 ladderz/pre_algebra/fn.is_composite.html create mode 100644 ladderz/pre_algebra/unit1/fn.is_composite.html diff --git a/ladderz/all.html b/ladderz/all.html index 48b2d15..afd8fea 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/pre_algebra/fn.is_composite.html b/ladderz/pre_algebra/fn.is_composite.html new file mode 100644 index 0000000..b5aeacf --- /dev/null +++ b/ladderz/pre_algebra/fn.is_composite.html @@ -0,0 +1,11 @@ +is_composite in ladderz::pre_algebra - Rust
pub fn is_composite(n: u32) -> bool
Expand description

Checks if a positive integer n is a composite number.

+

A composite number is a positive integer that is evenly divisible +by a positive integer other than 1 and itself.

+

Examples

+
use ladderz::pre_algebra::is_composite;
+
+assert!(!is_composite(1)); // 1 is not a composite number
+assert!(!is_composite(2)); // 2 is not a composite number
+assert!(is_composite(4)); // 4 is a composite number
+assert!(!is_composite(7)); // 7 is not a composite number
+
\ No newline at end of file diff --git a/ladderz/pre_algebra/fn.is_prime.html b/ladderz/pre_algebra/fn.is_prime.html index b1e493c..976a21b 100644 --- a/ladderz/pre_algebra/fn.is_prime.html +++ b/ladderz/pre_algebra/fn.is_prime.html @@ -1,6 +1,6 @@ is_prime in ladderz::pre_algebra - Rust

Function ladderz::pre_algebra::is_prime

source ·
pub fn is_prime(n: u32) -> bool
Expand description

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.

+

A prime number is a positive integer greater than 1 that is +not evenly divisible by any positive integer other than 1 and itself.

Examples

use ladderz::pre_algebra::is_prime;
 
diff --git a/ladderz/pre_algebra/index.html b/ladderz/pre_algebra/index.html
index 46c4cd3..da537b9 100644
--- a/ladderz/pre_algebra/index.html
+++ b/ladderz/pre_algebra/index.html
@@ -5,4 +5,4 @@
 let x: u32 = 10;
 println!("The factors of {x} are {:?}.", get_factors(x));
The factors of 10 are {1, 5, 2, 10}.
-

Functions

  • Finds all factor pairs for a positive integer n.
  • Finds all factors of a positive integer n.
  • Finds all the multiples of a positive integer n up to and including end (in the range [n, end]).
  • 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.
  • Checks if a positive integer n is a prime number.
\ No newline at end of file +

Functions

\ No newline at end of file diff --git a/ladderz/pre_algebra/sidebar-items.js b/ladderz/pre_algebra/sidebar-items.js index c47e697..387a36a 100644 --- a/ladderz/pre_algebra/sidebar-items.js +++ b/ladderz/pre_algebra/sidebar-items.js @@ -1 +1 @@ -window.SIDEBAR_ITEMS = {"fn":["get_factor_pairs","get_factors","get_multiples_in_range","is_factor","is_multiple","is_prime"]}; \ No newline at end of file +window.SIDEBAR_ITEMS = {"fn":["get_factor_pairs","get_factors","get_multiples_in_range","is_composite","is_factor","is_multiple","is_prime"]}; \ No newline at end of file diff --git a/ladderz/pre_algebra/unit1/fn.is_composite.html b/ladderz/pre_algebra/unit1/fn.is_composite.html new file mode 100644 index 0000000..227c392 --- /dev/null +++ b/ladderz/pre_algebra/unit1/fn.is_composite.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../../ladderz/pre_algebra/fn.is_composite.html...

+ + + \ No newline at end of file diff --git a/search-index.js b/search-index.js index dca17d1..0cb6ee0 100644 --- a/search-index.js +++ b/search-index.js @@ -1,5 +1,5 @@ var searchIndex = JSON.parse('{\ -"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 n.","Finds all factors of a positive integer n.","Finds all the multiples of a positive integer n up to and …","Checks if a positive integer x is a factor of another …","Checks if a positive integer x is a multiple of another …","Checks if a positive integer n 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"]]}\ +"ladderz":{"doc":"ladderz","t":"AFFFFFFF","n":["pre_algebra","get_factor_pairs","get_factors","get_multiples_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 n.","Finds all factors of a positive integer n.","Finds all the multiples of a positive integer n up to and …","Checks if a positive integer n is a composite number.","Checks if a positive integer x is a factor of another …","Checks if a positive integer x is a multiple of another …","Checks if a positive integer n is a prime number."],"i":[0,0,0,0,0,0,0,0],"f":[0,[1,2],[1,[[2,[1]]]],[[1,1],[[2,[1]]]],[1,3],[[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}; diff --git a/src/ladderz/pre_algebra/unit1.rs.html b/src/ladderz/pre_algebra/unit1.rs.html index 3e950bb..7b2fdb6 100644 --- a/src/ladderz/pre_algebra/unit1.rs.html +++ b/src/ladderz/pre_algebra/unit1.rs.html @@ -241,6 +241,41 @@ 241 242 243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278
use std::collections::HashSet;
 
 /// Finds all factor pairs for a positive integer `n`.
@@ -381,8 +416,8 @@
 
 /// 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.
+/// A prime number is a positive integer greater than 1 that is
+/// not evenly divisible by any positive integer other than 1 and itself.
 ///
 /// # Examples
 ///
@@ -411,6 +446,30 @@
     true
 }
 
+/// Checks if a positive integer `n` is a composite number.
+///
+/// A composite number is a positive integer that is evenly divisible
+/// by a positive integer other than 1 and itself.
+///
+/// # Examples
+///
+/// ```rust
+/// use ladderz::pre_algebra::is_composite;
+///
+/// assert!(!is_composite(1)); // 1 is not a composite number
+/// assert!(!is_composite(2)); // 2 is not a composite number
+/// assert!(is_composite(4)); // 4 is a composite number
+/// assert!(!is_composite(7)); // 7 is not a composite number
+/// ```
+pub fn is_composite(n: u32) -> bool {
+    for num in 1..n {
+        if n % num == 0 && num != 1 && num != n {
+            return true;
+        }
+    }
+    false
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
@@ -483,5 +542,16 @@
         assert!(is_prime(23));
         assert!(!is_prime(9514));
     }
+
+    #[test]
+    fn test_is_composite() {
+        assert!(!is_composite(1));
+        assert!(!is_composite(2));
+        assert!(!is_composite(3));
+        assert!(is_composite(4));
+        assert!(is_composite(8));
+        assert!(is_composite(27));
+        assert!(is_composite(51));
+    }
 }
 
\ No newline at end of file