babel-plugin-transform-bigint icon indicating copy to clipboard operation
babel-plugin-transform-bigint copied to clipboard

avoid maybeJSBI

Open Yaffle opened this issue 2 years ago • 0 comments

    function legendre(a, n) {
        if (typeof a !== 'number' || typeof n !== 'number') {
          throw new TypeError();
        }
        a = a | 0;
        n = n | 0;
        a = a % n;
        var t = 1;
        var r = 0;
        while (a !== 0) {
            while ((a & 1) === 0) {
                a >>= 1;
                r = n & 7;
                if (r === 3 || r === 5) {
                    t = -t;
                }
            }
            r = n;
            n = a;
            a = r;
            if ((a & 3) === 3 && (n & 3) === 3) {
                t = -t;
            }
            a = a % n;
        }
        return n === 1 ? t : 0;
    }

Yaffle avatar Apr 19 '23 08:04 Yaffle