Skip to content

IntTryJacobi

Description

Compute the Jacobi symbol (a/n).

Parameters

Name Direction Description
a in Numerator
n in Odd positive modulus
error out Optional pointer set to true on failure and false on success

Usage example (from documentation)

  int symbol = IntJacobi(&a, &n);

Returns

-1, 0, or 1, or 0 on failure.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    bool IntTryJacobi(int *out, Int *a, Int *n) {
        ValidateInt(a);
        ValidateInt(n);
    int IntJacobiWithError(Int *a, Int *n, bool *error) {
        int  out = 0;
        bool ok  = IntTryJacobi(&out, a, n);
    
        if (error) {
        {
            int jacobi = 0;
            if (!IntTryJacobi(&jacobi, &a, modulus) || jacobi != 1) {
                IntDeinit(&a);
                return false;
                int jacobi = 0;
    
                if (!IntTryJacobi(&jacobi, &z, modulus)) {
                    IntDeinit(&q);
                    IntDeinit(&z);
        int  symbol = 99;
        bool error  = false;
        bool result = !IntTryJacobi(&symbol, &a, &n);
    
        result = result && (IntJacobi(&a, &n, &error) == 0);
Last updated on