IsPrime[A: (UnsignedInteger[A] val & (U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val))]¶
Primality test using 6k ± 1 method.
All integers (excluding 2 and 3), can be expressed as (6k + i), where i = −1, 0, 1, 2, 3, or 4. Since 2 divides (6k + 0), (6k + 2), and (6k + 4), while 3 divides (6k + 3) that leaves only (6k - 1) and (6k + 1) for expressing primes.
primitive val IsPrime[A: (UnsignedInteger[A] val & (U8 val | U16 val | U32 val |
U64 val | U128 val | ULong val |
USize val))]
Constructors¶
create¶
Returns¶
- IsPrime[A] val^
Public Functions¶
apply¶
Parameters¶
- n: A
Returns¶
- Bool val
eq¶
Parameters¶
- that: IsPrime[A] val
Returns¶
- Bool val
ne¶
Parameters¶
- that: IsPrime[A] val
Returns¶
- Bool val