1 unstable release
0.2.21  Jul 28, 2023 

0.2.19 

0.1.24 

#4 in #sample
32 downloads per month
36KB
486 lines
PrimeChecker
A sample rust package to check the primeness of a given unsigned, 64bit integer.
Description
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 primeness values:
 Prime: The list of its factors is exactly
[1, num]
.  Composite: The list of its factors is
[1, [z ( Z], num]
wherez
can be any natural number exclusively between1
andnum
.  AntiPrime: The list of its factors is the same as a composite number (except in special cases, such as
1
,2
) but the length of the list is the greatest for the set [numz
,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, 64bit integers depending on these three criteria.
Documentation
The autogenerated Rust documentation can be viewed at the Docs.RS website.
It may take a few hours for docs to propagate after a new version has been uploaded, you can check the build queue here.
Here we will go over the very basics of the functions defined in the lib.rs
file.

is_hcn()

Checks if the given number is a highlycomposite (antiprime) number.

Arguments:
num: u64

Returns:
bool  default: false
,Vec<u64>
where thevector
is list of the given number,num
's factors. 
Usage:
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<u64>; (check, factors) = prime_checker::is_hcn(num: num); if check == true{ println!("{} is a highly composite number.", num); } else { println!("{} is not a highly composite number; here are its factors: {:?}", num, factors); } }


is_prime()

Checks if the given number is a prime number.

Arguments:
num: u64

Returns:
bool  default: false
,Vec<u64>
where thevector
is list of the given number,num
's factors. 
Usage:
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<u64>; (check, factors) = prime_checker::is_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()

Returns a brief description of this library crate and if
show
is set totrue
, prints the same to the console. 
Arguments:
show: bool

Returns:
String

Usage:
use prime_checker; fn main(){ let desc_str = prime_checker::description(true); }


get_primes()

Finds all prime numbers which are less than or equal to the given number.

Arguments:
num: u64

Returns:
Vec<u64>
where thevector
is list all prime numbers which are less than or equal to the given number,num
. 
Usage:
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<u64>; prime_numbers = prime_checker::get_primes(num: num); println!("The prime numbers till {} are:\t{:?}", num, prime_numbers); }


get_hcn()

Finds all antiprime numbers which are less than or equal to the given number.

Arguments:
num: u64

Returns:
Vec<u64>
which is the list of all highlycomposite numbers less than or equal to the given number,num
. 
Usage:
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 anti_prime_numbers: Vec<u64>; anti_prime_numbers = prime_checker::get_hcn(num: num); println!("The antiprime numbers till {} are:\t{:?}", num, anti_prime_numbers); }

WARNING: HIGHLY Unoptimized and Computationally Expensive[^1].

Development and Contribution
If you want to contribute to this library, kindly follow the steps described below.
Contribution Workflow
 Assign or ask a moderator to assign yourself to the required issue; this is to ensure that the same issue is not being independently resolved by two or more unrelated parties.
 If not already done, fork the repository to your own github account.
 If this is your first time contributing, follow the steps given in the following section to set up the development environment.
 Checkout a branch named as an urlsafe version of the issue number.
 Suppose the issue number is
Misc_001
, then the branch name will bemisc001
.
 Suppose the issue number is
 Make the code changes as required.
 Also, write any additional testcases required in the required module/file.
 Run
cargo test verbose
to make sure everything works and is validated. Do NOT proceed further until all tests pass.
 Commit your changes with a meaningful commit message.
 Merge with the
master
branch of the main repository and run all tests again. Do NOT proceed further until all tests pass.
 Push to the origin.
 Create a new
Pull Request
to themaster
branch of the main repository with the required details and a sensiblePR
title.  If review changes are requested, repeat steps #59 until no more changes are requested.
Development Environment Setup
Make sure the prerequisites 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.
PreRequisites
 Rust Compiler
 v1.6+ (stable)
 BASH
 GitBash for Windows
 Cargo
Steps

chmod +x scripts/*
to give all scripts in thescripts
directory permission to execute. You really should go through the scripts before doing this; just good practice.

sh scripts/build.sh both
to build both, therelease
anddebug
versions of the library. 
cargo test verbose
to make sure everything was copied correctly and is working as intended.
Credits
(ɔ) 2023 Arkiralor (Prithoo Medhi)
[^1]: Takes approximately 64 seconds to check 6'160 values beyond the last element of prime_checker::libs::constants::KNOWN_ANTIPRIMES
.
Dependencies
~11KB