require("big-integer"); let i, j, k, val; for(i = 1; i <= 100; i++) { for(j = 1; j <= 100; j++) { for(k = 1; k <= 100; k++) { for(l = 1; l <= 100; l++) { val = BigInteger(Number.MAX_SAFE_INTEGER).plus(i) val = val.plus(j); val = val.multiply(k); val = val.mod(l); } } } } real 0m41.659s user 0m42.663s sys 0m0.932s