Skip to content

IsPrime[A: (UnsignedInteger[A] val & (U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val))]

[Source]

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

[Source]

new val create()
: IsPrime[A] val^

Returns


Public Functions

apply

[Source]

fun box apply(
  n: A)
: Bool val

Parameters

  • n: A

Returns


eq

[Source]

fun box eq(
  that: IsPrime[A] val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: IsPrime[A] val)
: Bool val

Parameters

Returns