A sample rust package to check the prime-ness of a given unsigned, 64-bit integer.
Do note that wherever we use square brackets in this section, we are using the mathematical expression for an inclusive boundary.
Any whole number (or natural number, depending on who you ask) num
, can have one of the following three prime-ness values:
[1, num]
.[1, [z (- Z], num]
where z
can be any natural number exclusively between 1
and num
.1
, 2
) but the length of the list is the greatest for the set [num-z
, num
] i.e, it exclusively has the highest number of factors for any natural number less than it.The library here holds functions that help determine and select unsigned, 64-bit integers depending on these three criteria.
As this entire package is a cargo crate, you can generate the documentation using cargo doc
to get specific details, as well. Here we will go over the very basics of the functions defined in the lib.rs
file.
check_if_anti_prime()
num: u64
bool | default: false
, Vec<u64>
where the vector
is list of the given number, num
's factors.Usage:
```rs use prime_checker;
fn main(){
let num: u64 = z; // z belongs to the set of natural numbers and is only used as a placeholder by us in this README.
let check: bool;
let factors: Vec
(check, factors) = prime_checker::check_if_anti_prime(num: num);
if check == true{
println!("{} is an anti-prime number.", num);
}
else {
println!("{} is not an anti-prime number; here are its factors: {:?}", num, factors);
}
} ```
check_if_prime()
num: u64
bool | default: false
, Vec<u64>
where the vector
is list of the given number, num
's factors.Usage:
```rs use prime_checker;
fn main(){
let num: u64 = z; // z belongs to the set of natural numbers and is only used as a placeholder by us in this README.
let check: bool;
let factors: Vec
(check, factors) = prime_checker::check_if_prime(num: num);
if check == true{
println!("{} is a prime number.", num);
}
else {
println!("{} is not a prime number; here are its factors: {:?}", num, factors);
}
} ```
description()
NULL
NULL
Usage:
```rs use prime_checker;
fn main(){ prime_checker::description(); } ```
find_primes_till()
num: u64
Vec<u64>
where the vector
is list all prime numbers which are less than or equal to the given number, num
.Usage:
```rs use prime_checker;
fn main(){
let num: u64 = z; // z belongs to the set of natural numbers and is only used as a placeholder by us in this README.
let prime_numbers: Vec
prime_numbers = prime_checker::find_primes_till(num: num);
println!("The prime numbers till {} are:\t{:?}", num, prime_numbers);
} ```
If you want to contribute to this library, kindly follow the steps described below.
Misc_001
, then the branch name will be misc-001
.cargo test --verbose
to make sure everything works and is validated.
master
branch of the main repository and run all tests again.
Pull Request
to the master
branch of the main repository with the required details and a sensible PR
title.Make sure the pre-requisites are satified before proceeding further.
DO NOT use the nightly
build of Rust for this. We cannot vouch for any behaviour due to differences between the stable
and nightly
builds.
chmod +x scripts/*
to give all scripts in the scripts
directory permission to execute.
sh scripts/build.sh both
to build both, the release
and debug
versions of the library.cargo test --verbose
to make sure everything was copied correctly and is working as intended.(ɔ) 2023 Arkiralor (Prithoo Medhi)