1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Convenience wrapper for machine-prime. Implements primality testing for all primitive types, including floats.
//! Provides iterators and const functions, and modeling of prime sets.
//! Primes here are defined as integers that can only be composed of themselves and a unit of the integers {1,-1}.
//! Therefore numbers with no factor P are primes as well as -P.
//! ```
//! use c_prime::{P,Primality,prime_array,prime_inv_array};
//!
//! // The set of P contains 17
//! assert_eq!(P.contains(17),true);
//!
//! // Go to 2^128-1000 and count the primes from there up to 2^128
//! assert_eq!(P.jump_to(u128::MAX-999).count(),9);
//! // Count the number of primes under 100
//! assert_eq!(P.take_while(|x| *x < 100).count(),25);
//!
//! // Set intersection of the primes and some collection
//! assert_eq!(P.intersection([2,4,5,6,7]),[2,5,7]);
//!
//! // The first 25 primes greater than 100
//! const ODD_PRIMES : [u128;25] = prime_array(100);
//! // The multiplicative inverses of these primes
//! const PRIME_INV : [u128;25] = prime_inv_array(100);
//! // P*P^-1 = 1
//! for (p,inv) in ODD_PRIMES.iter().zip(PRIME_INV.iter()){
//! assert_eq!(p.wrapping_mul(*inv),1)
//! }
//! // Of course floats can also be primes so long as they can accurately store them
//! // Here the value is prime so strong case is faster at evaluating it
//! assert!(4294967291f64.strong_case());
//! // Another strong case
//! assert!(!(10570841f64*10570849f64).strong_case());
//! ```
//#![feature(generic_const_items)]
pub
pub
pub
pub
pub
pub use cratePrimality;
pub use crate*;
pub use crate*;
pub use crate*;