prime test

Benchmark created on


Preparation HTML

<script>
  function factorialMod(x, p) {
      if( x === 0 ) return 1;
      return (x * factorialMod(x-1,p)) % p;
  }
  function isPrime1 (p) {
    return (factorialMod(p-1,p)+1) % p === 0;
  }
  
  function isPrime2 (p) {
      for (var i = 2, sqr = Math.sqrt(p) ; i < sqr ; i++) {
          if (p % i === 0) return false;
      }
      return true;
  }
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
brut
isPrime2(24)
isPrime2(45)
isPrime2(23)
isPrime2(65)
isPrime2(76)
isPrime2(87)
ready
test
isPrime1(24)
isPrime1(45)
isPrime1(23)
isPrime1(65)
isPrime1(76)
isPrime1(87)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.