dkh.numeric.prime

  • Declaration

    ulong ulongPowMod(U)(ulong x, U n, ulong md) if (isIntegral!U || is(U == BigInt));

  • Declaration

    T[] divisorList(T)(T x);

    xの約数一覧を返す

    Examples

    1. import std.range, std.algorithm; assert(equal(divisorList(1), [1])); assert(equal(divisorList(2), [1, 2])); assert(equal(divisorList(4), [1, 2, 4])); assert(equal(divisorList(24), [1, 2, 3, 4, 6, 8, 12, 24]));

  • Declaration

    T[] factorList(T)(T x);

    xの素因数一覧を返す

    Examples

    1. import std.range, std.algorithm; assert(equal(factorList(1), new int[0])); assert(equal(factorList(2), [2])); assert(equal(factorList(4), [2, 2])); assert(equal(factorList(24), [2, 2, 2, 3]));

  • Declaration

    bool isPrime(ulong n);

    Millar-Rabin Test

    Examples

    1. assert(!isPrime(0)); assert(!isPrime(1)); assert(isPrime(2)); assert(isPrime(10^^9 + 7));