Skip to content

IntJacobi

IntJacobi

Description

Compute the Jacobi symbol (a/n).

Aborts when n is zero or even.

Parameters

Name Direction Description
a in Numerator
n in Odd positive modulus

Usage example (from documentation)

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

Returns

-1, 0, or 1.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    int IntJacobi(Int *a, Int *n) {
        ValidateInt(a);
        ValidateInt(n);
            return false;
        }
        if (IntJacobi(&a, modulus) != 1) {
            IntDeinit(&a);
            return false;
            }
    
            while (IntJacobi(&z, modulus) != -1) {
                MISRA_PRIV_IntAddU64(&z, &z, 1);
            }
    
    bool test_int_jacobi(void) {
        WriteFmt("Testing IntJacobi\n");
    
        Int a = IntFrom(5);
        Int n = IntFrom(21);
    
        bool result = IntJacobi(&a, &p) == -1;
        result      = result && (IntJacobi(&b, &n) == 0);
    
        bool result = IntJacobi(&a, &p) == -1;
        result      = result && (IntJacobi(&b, &n) == 0);
    
        IntDeinit(&a);
    
    bool test_int_jacobi_even_denominator(void) {
        WriteFmt("Testing IntJacobi even denominator handling\n");
    
        Int a = IntFrom(3);
        Int n = IntFrom(8);
    
        (void)IntJacobi(&a, &n);
        return false;
    }
Last updated on