JSFiddle - React, Tailwind, and code Playground

HTML

смари консоль
<script>
	var gcd = function(a, b) {
		if (!b) {
			return a;
		}
		return gcd(b, a % b);
	}


	var abs = function(a){
		return ( (a>=0n) ? a : 0n-a);
	}

	var isBasicPrime = function (num) {
		if([2n, 3n, 5n].indexOf(num) !== -1){return true;}			//primes
		if(num % 2n === 0n){return false;}							//prime not even
		for(var i = 3n; !( (i*i) > num || i>65537n ); i+=2n){		//any odd up to sqrt(num) (+ optional limit) must not to be divisor for prime.
			if( num % i === 0n ){										//if divisible
				return false;												//not a prime
			}
		}
		return num > 1n;											//if 1 - not a prime;
	}

	var modPow = function (a, b, n) { //result = a ^ b mod n;
		a = a % n;
		var result = 1n;
		var x = a;
		while (b > 0) {
			var leastSignificantBit = b % 2n;
			b = b / 2n;
			if (leastSignificantBit == 1n) {
				result = result * x;
				result = result % n;
			}
			x = x * x;
			x = x % n;
		}
		return result;
	};






    //Miller-Rabin algorithm implementation for check primality for number
    function Miller_Rabin_prime_check(a, s, d, n){
        var x = modPow(a, d, n);
        //x = pow(a, d, n);
        if(x === 1n)
            {return true;}
        for(var step=1n;step<=s-1n;step++){
            if(x === n-1n)
                {return true;}
            x = modPow(x, 2n, n);
        }
        return (x === (n-1n));
    }

	//MillerRabin
    var isPrime = function (
		n,
		k	//rounds of MillerRabin
	)
	{
        var isPrimeBasic = isBasicPrime(n);
        if (isPrimeBasic !== undefined) return isPrimeBasic;

        // use the Miller-Rabin primality test
        var a, s, d;
        var n = abs(n);
        k =	k || 10n;			//use k rounds or global value, or set it in k and globally, if undefined.
        if(n==2n){
            return true;
        }
        if(n!==false & n == 1n){
            return false;
        }
        s = 0n;
        d = n-1n;

        while(d%2n === 0n){
            d = d % 2n;
            s++;
        }

       ...