diff --git a/ladderz/all.html b/ladderz/all.html index 03c9b05..bd5f656 100644 --- a/ladderz/all.html +++ b/ladderz/all.html @@ -1 +1 @@ -
pub fn get_prime_factorization(n: u32) -> HashMap<u32, u32>Write a program that determines the prime factorization of a positive integer n.
For example the prime factorization of 12 is 22 * 31, and the output is a HashMap of the form
+[(2, 2), (3, 1)] where the first element of each tuple is the prime factor and the second element is the exponent.
use ladderz::pre_algebra::get_prime_factorization;
+use std::collections::HashMap;
+
+let result: HashMap<u32, u32> = get_prime_factorization(12);
+let expected: HashMap<u32, u32> = [(2, 2), (3, 1)].into();
+assert_eq!(result, expected);pub fn get_primes_in_range(start: u32, n: u32) -> HashSet<u32>Write a program that finds all prime numbers of a positive integer n in the range [start, n].
A prime number is a positive integer greater than 1 that is +not evenly divisible by any positive integer other than 1 and itself.
+use ladderz::pre_algebra::get_primes_in_range;
+use std::collections::HashSet;
+
+let result: HashSet<u32> = get_primes_in_range(2, 10);
+let expected: HashSet<u32> = [2, 3, 5, 7].into();
+assert_eq!(result, expected);The factors of 10 are {1, 5, 2, 10}.
-n.n.n up to and including end (in the range [n, end]).n is a composite number.x is a factor of another positive integer y.x is a multiple of another positive integer y.n is a prime number.