Prime-Checker

A sample rust package to check the prime-ness of a given unsigned, 64-bit 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 prime-ness values:

  1. Prime: The list of its factors is exactly [1, num].
  2. Composite: The list of its factors is [1, [z (- Z], num] where z can be any natural number exclusively between 1 and num.
  3. Anti-Prime: 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 [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.

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.

  1. check_if_anti_prime()

  2. check_if_prime()

  3. description()

  4. find_primes_till()

  5. find_anti_primes_till()

Development and Contribution

If you want to contribute to this library, kindly follow the steps described below.

Contribution Workflow

  1. 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.
  2. If not already done, fork the repository to your own github account.
  3. If this is your first time contributing, follow the steps given in the following section to set up the development environment.
  4. Checkout a branch named as an url-safe version of the issue number.
  5. Make the code changes as required.
  6. Run cargo test --verbose to make sure everything works and is validated.
  7. Commit your changes with a meaningful commit message.
  8. Merge with the master branch of the main repository and run all tests again.
  9. Push to the origin.
  10. Create a new Pull Request to the master branch of the main repository with the required details and a sensible PR title.
  11. If review changes are requested, repeat steps #5-9 until no more changes are requested.

Development Environment Setup

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.

Pre-Requisites

  1. Rust Compiler
  2. BASH
  3. Cargo

Steps

  1. chmod +x scripts/* to give all scripts in the scripts directory permission to execute.

  2. sh scripts/build.sh both to build both, the release and debug versions of the library.
  3. cargo test --verbose to make sure everything was copied correctly and is working as intended.

Credits

(ɔ) 2023 Arkiralor (Prithoo Medhi)