Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/izyuumi/primality
Check if a number is prime in Rust
https://github.com/izyuumi/primality
math number prime rust
Last synced: about 4 hours ago
JSON representation
Check if a number is prime in Rust
- Host: GitHub
- URL: https://github.com/izyuumi/primality
- Owner: izyuumi
- License: mit
- Created: 2024-03-17T23:46:23.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-18T00:15:43.000Z (8 months ago)
- Last Synced: 2024-11-11T02:12:17.461Z (9 days ago)
- Topics: math, number, prime, rust
- Language: Rust
- Homepage: https://crates.io/crates/primality
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# primality
Trait to check if a number is prime.
## Installation
Add the following to your `Cargo.toml`:
```toml
[dependencies]
primality = "0.1"
```Or run the following command:
```sh
cargo add primality
```## Usage
```rust
use primality::IsPrime;assert!(2i8.is_prime());
assert!(3usize.is_prime());
assert!(5u128.is_prime());
assert!(7i64.is_prime());assert!(!4i16.is_prime());
assert!(!6u16.is_prime());
assert!(!8u32.is_prime());
assert!(!9i128.is_prime());
```## Supported Number Types
- `u8`
- `u16`
- `u32`
- `u64`
- `u128`
- `usize`
- `i8`
- `i16`
- `i32`
- `i64`
- `i128`
- `isize`## License
This project is licensed under the [MIT license](LICENSE).